本文整理汇总了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();