本文整理匯總了TypeScript中prompt.start函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript start函數的具體用法?TypeScript start怎麽用?TypeScript start使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了start函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: Promise
return new Promise((resolve, reject) => {
prompt.message = '';
prompt.start();
let schema = {
properties: {
clientId: {
default: this.clientId,
},
clientSecret: {
default: this.clientSecret,
},
endpoint: {
default: this.endpoint,
},
},
};
prompt.get(schema, (err, result) => {
if (result === undefined) {
return;
}
this.copyFrom(result);
this.write();
resolve(this);
});
});
示例2: printBalance
await printBalance(async (balance) => {
const amt = parseFloat(args[1]);
const address = args[2];
if (isNaN(amt)) {
console.log(red('Must provide a valid number with maximum of 6 digits ie 10.356784'));
process.exit(1);
}
if (!address) {
console.log(red('Must provide a valid recipient address'));
process.exit(1);
}
if (amt > balance) {
console.log(red(`You don't have enough ${MOSAIC_NAME} to send`));
process.exit(1);
}
try {
const preTransaction = await prepareTransfer(address, amt);
const xemFee = (preTransaction.fee / 1e6).toString();
console.log(white('Transaction Details: \n'));
console.log(`Recipient: ${yellow(address)}\n`);
console.log(`${MOSAIC_NAME} to send: ${yellow(amt.toString())}\n`);
console.log(`XEM Fee: ${yellow(xemFee)}\n\n`);
console.log(`${white('Would you like to proceed?\n')}`);
prompt.message = white(`${MOSAIC_NAME} Transfer`);
prompt.start();
prompt.get({
properties: {
confirmation: {
description: yellow('Proceed? ( y/n )')
}
}
}, async (_, result) => {
if (result.confirmation.toLowerCase() === 'y' || result.confirmation.toLowerCase() === 'yes') {
try {
const result = await sendMosaic(address, amt, selectedAccount);
console.log(result);
console.log('\n\n');
console.log(white('Transaction successfully announced to the NEM blockchain. Transaction could take some time. Come back here in 5 minutes to check your balance to ensure that the transaction was successfully sent\n'));
} catch (err) {
console.log(red(err));
}
} else {
console.log('Transaction canceled');
process.exit(1);
}
});
} catch (err) {
console.log(`\n${err}\n`);
}
});
示例3: input
public static input(cb: any) {
//var re = RuleEngine.getREInst();
RuleEngine.async_hold = true;
if(is_debug) {
console.log("_dbg in input");
console.log("_dbg rule_firing # b_args: " + RuleEngine.rule_firing.b_args.length);
//console.log("_dbg RuleEngine.body_rule_firing.name: " + RuleEngine.body_rule_firing.name);
}
if(Util.is_in_browser()) {
var input_div = document.getElementById("input_div");
input_div.style.display = "inline";
RuleEngine.input_cb = cb;
//var input_str = window.prompt("Enter input", "Enter yes or no");
//cb(input_str);
} else {
var prompt = require('prompt');
prompt.start();
prompt.get(['input_str'], function (err, result) {
if (err) { return onErr(err); }
if(is_debug) {
console.log('Command-line input received:');
console.log(' input_str: ' + result.input_str);
}
//console.log("_dbg after RuleEngine.body_rule_firing.name: " + RuleEngine.body_rule_firing.name);
cb(result.input_str);
//re.handleAsyncInput(result.input_str);
//console.log(' Email: ' + result.email);
});
function onErr(err) {
console.log(err);
return 1;
}
/*
var fs = require('fs');
console.log("\npress ctrl-d ctrl-d when done with input...\n");
var input_str = fs.readFileSync('/dev/stdin', 'utf-8');
*/
}
//re.handleAsyncInput(input_str);
//return input_str;
}
示例4: Promise
return new Promise((res, rej) => {
prompt.start()
const schema = {
properties: {
confirm: {
type: 'string',
description: 'Are you sure you want to delete these files? Please check carefully',
default: 'n',
required: true
}
}
}
prompt.get(schema, function (err, result) {
if (err) return rej(err)
return res(result.confirm && result.confirm.match(/y/) !== null)
})
})
示例5: Promise
return new Promise((res, rej) => {
prompt.start()
const schema = {
properties: {
password: {
hidden: true,
required: true
}
}
}
prompt.get(schema, function (err, result) {
if (err) {
return rej(err)
}
return res(result.password)
})
})
示例6: white
const createPwd = () => {
console.log(white(
`\nPlease enter a unique password ${yellow('(8 character minimum)')}.\n
This password will be used to encrypt your private key and make working with your wallet easier.\n\n`
));
console.log(red(
`Store this password somewhere safe. If you lose or forget it you will never be able to transfer funds\n`
));
prompt.message = white(`${MOSAIC_NAME} wallet`);
prompt.start();
prompt.get({
properties: {
password: {
description: white('Password'),
hidden: true
},
confirmPass: {
description: white('Re-enter password'),
hidden: true
}
}
}, async (_, result) => {
if (result.password !== result.confirmPass) {
console.log(magenta('\nPasswords do not match.\n\n'));
createPwd();
} else {
/**
* Create new SimpleWallet
* Open it to access the new Account
* Print account info
*/
const wallet = createSimpleWallet(result.password);
const pass = new Password(result.password);
const account = wallet.open(pass);
const address = account.address.pretty();
console.log(green(`${MOSAIC_NAME} wallet successfully created.`));
console.log(white(`You can now start sending and receiving ${MOSAIC_NAME}!`));
console.log(white(`\n${MOSAIC_NAME} Public Address:`));
console.log(yellow(`${address}`));
console.log(white(`\nPrivate Key:`));
console.log(yellow(`${account.privateKey}`));
await downloadWallet(wallet);
}
})
};
示例7: function
return new Promise<void>(function(fulfill, reject) {
Prompt.message = '';
Prompt.delimiter = '';
Logger.hideLabels().info('').showLabels();
Prompt.start();
Prompt.get(promptSchema, function(err, result) {
if (err) {
reject(err);
}
else {
_generate(result.name, result.location);
fulfill(undefined);
}
});
});
示例8: function
var startPrompt = function() {
pr.start();
pr.message = '';
pr.delimiter = '>';
pr.get('command', (err, result) => {
result.command = result.command.trim();
var splitcmd = result.command.split(' ');
if (splitcmd.length > 1) {
result.command = splitcmd[0].trim();
result.params = splitcmd.slice(1);
}
if(commands[result.command]) {
commands[result.command].execute(result.params);
} else {
unknowncmd(result.command);
}
});
};
示例9: inputRadio
public static inputRadio(cb: any, radio_data) {
//var re = RuleEngine.getREInst();
RuleEngine.async_hold = true;
if(is_debug) {
console.log("_dbg in input");
console.log("_dbg rule_firing # b_args: " + RuleEngine.rule_firing.b_args.length);
//console.log("_dbg RuleEngine.body_rule_firing.name: " + RuleEngine.body_rule_firing.name);
}
if(Util.is_in_browser()) {
var radio_input_div = document.getElementById("radio_input_div");
var btn_string = '';
var radio_btn_cnt = 0;
for(var k in radio_data) {
radio_btn_cnt++;
if(radio_data.hasOwnProperty(k)) {
console.log('key is: ' + k + ', value is: ' + radio_data[k]);
btn_string += '<label for="radB' + radio_btn_cnt + '" class="txtradbttn"><input id="radB' + radio_btn_cnt + '" type="radio" class="processor' + radio_btn_cnt + '" name="radio_input" value="' + radio_data[k] + '">'+k+'</label>';
}
}
console.log("_dbg btn_string: " + btn_string);
if(RuleEngine.use_continue_btn == true) {
$('#radio_input_div').html('\
<form id="radio_input_form" method="POST" onsubmit="return false;">\
' + btn_string + ' \
<input type="submit" value="Submit" onclick="Util.handle_radio_input();">\
</form>');
} else {
$('#radio_input_div').html('\
<form id="radio_input_form" method="POST" onsubmit="Util.handle_radio_input();return false;">\
' + btn_string + ' \
</form>');
$('input[type="radio"][name="radio_input"]').click(function () { var closestForm = $(this).parents('form'); closestForm.submit();});
}
//document.forms['radio_input_form'].parentNode.removeChild(document.forms['radio_input_form']);
/*
for(var i = 0; i < radio_btns.length; i++) {
radio_btns[i].parentNode.removeChild(radio_btns[i]);
} */
radio_input_div.style.display = "inline";
RuleEngine.input_cb = cb;
//var input_str = window.prompt("Enter input", "Enter yes or no");
//cb(input_str);
} else {
var prompt = require('prompt');
prompt.start();
prompt.get(['input_str'], function (err, result) {
if (err) { return onErr(err); }
if(is_debug) {
console.log('Command-line input received:');
console.log(' input_str: ' + result.input_str);
}
//console.log("_dbg after RuleEngine.body_rule_firing.name: " + RuleEngine.body_rule_firing.name);
cb(result.input_str);
//re.handleAsyncInput(result.input_str);
//console.log(' Email: ' + result.email);
});
function onErr(err) {
console.log(err);
return 1;
}
/*
var fs = require('fs');
console.log("\npress ctrl-d ctrl-d when done with input...\n");
var input_str = fs.readFileSync('/dev/stdin', 'utf-8');
*/
}
//re.handleAsyncInput(input_str);
//return input_str;
}