当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript prompt.start函数代码示例

本文整理汇总了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);
            });
        });
开发者ID:victorjacobs,项目名称:chullo-client,代码行数:28,代码来源:configuration.ts

示例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`);
				}
			});
开发者ID:devslopes,项目名称:mosaic-cli-wallet,代码行数:52,代码来源:wallet-cli.ts

示例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;
  }
开发者ID:wheath,项目名称:jsrule-engine,代码行数:48,代码来源:Util.ts

示例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)
   })
 })
开发者ID:jiang263,项目名称:PeerTube,代码行数:17,代码来源:prune-storage.ts

示例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)
   })
 })
开发者ID:jiang263,项目名称:PeerTube,代码行数:17,代码来源:import-videos.ts

示例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);
		}
	})
};
开发者ID:devslopes,项目名称:mosaic-cli-wallet,代码行数:45,代码来源:wallet-cli.ts

示例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);
			}
		});

	});
开发者ID:bitpi,项目名称:Obsidian-Server,代码行数:20,代码来源:project_generator.ts

示例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);
        }
    });
};
开发者ID:pierreca,项目名称:dashboards,代码行数:20,代码来源:ghprompt.ts

示例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;
  }
开发者ID:wheath,项目名称:jsrule-engine,代码行数:85,代码来源:Util.ts


注:本文中的prompt.start函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。