本文整理匯總了TypeScript中promptly.prompt函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript prompt函數的具體用法?TypeScript prompt怎麽用?TypeScript prompt使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了prompt函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: save
let checkOutput = (configString: string) => {
if (configurit["output-file"]) {
save(configString, configurit["output-file"]);
}
Promptly.prompt("Output file: ", { validator: null }, (err: Error, value: string) => {
save(configString, value);
});
}
示例2: reject
return new Promise<AuthInfo>((resolve, reject) => {
promptly.prompt("Name: ", (error, name) => {
if (error) {
reject(error);
}
promptly.password("Password: ", (error, password) => {
resolve({username: name, password: password});
if (error) {
reject(error);
}
});
});
});
示例3: viewNotesByText
function viewNotesByText() {
promptly.prompt('Enter note text to search for: ', (err, value) => {
console.log("Retrieving notes...");
noteApi.getAllWithText({ text: value }).then(notes => {
console.log(`Note count: ${notes.length}`);
outputNotes(notes);
}).catch(err => {
console.log(err.toString());
}).then(() => {
selection();
});
});
}
示例4: addNote
function addNote() {
promptly.prompt('Enter note text: ', (err, value) => {
console.log("Adding note...");
noteApi.add({
creationDate: new Date(),
text: value
}).then(() => {
console.log("Added note.");
}).catch(err => {
console.log(err.toString());
}).then(() => {
selection();
})
});
}
示例5: if
return new Promise<any>((resolve, reject) => {
let prompt = "\r\n\r\n";
if (propertyDefinition.title) {
prompt += propertyDefinition.title + "\r\n";
}
if (propertyDefinition.description) {
prompt += propertyDefinition.description + "\r\n";
}
if (currentValue !== undefined) {
prompt += "(current value: " + currentValue + ")\r\n";
}
prompt += propertyName;
Promptly.prompt(prompt + " >", (err: Error, value: string) => {
if (err) {
reject(err);
}
if (propertyDefinition.type === "boolean") {
if (value === "true" || value === "t" || value === "y" || value === "yes") {
resolve(true);
}
else {
resolve(false);
}
}
else if (propertyDefinition.type === "number") {
resolve(parseFloat(value));
}
else if(propertyDefinition.type === "integer") {
resolve(parseInt(value));
}
else {
resolve(value);
}
});
})
示例6: readSchema
}
let save = (configString: string, path: string) => {
FileSystem.writeFile(path, configString, (error: Error) => {
console.log("done writing");
process.exit(0);
});
}
if(configurit["schema-location"]) {
readSchema(configurit["schema-location"]);
}
else {
Promptly.prompt("Schema location: ", { validator: null }, (err: Error, value: string) => {
//configWriter.set("name", value);
readSchema(value);
});
}
/*
let i = 0;
let counts = {
"": 0
}
let getDetails = (objectName?: string) => {
if (counts[objectName] === undefined) {
counts[objectName] = 0;
}
let properties = schemaReader.getProperties();