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


TypeScript commander.outputHelp函数代码示例

本文整理汇总了TypeScript中commander.outputHelp函数的典型用法代码示例。如果您正苦于以下问题:TypeScript outputHelp函数的具体用法?TypeScript outputHelp怎么用?TypeScript outputHelp使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了outputHelp函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

program.version('0.0.1')
       .usage('[options] server')
       .option('-p, --port <n>', 'Specify the port', parseInt)
       .option('-i, --insecure <b>', 'allow self-signed certificates')
       .arguments('<server>').action(function(server) {
            serverValue = server;
});

serverValue = serverValue ? serverValue : URLHelper.combineURLParts(GlobalConfig.proxy.baseURL, GlobalConfig.proxy.nameSpace);

program.parse(process.argv);

if (typeof serverValue === 'undefined') {
    console.error('No server specified!');
    program.outputHelp();
    process.exit(1);
}

portValue = program.port || 5050;
insecureValue = program.insecure || false;


var proxy = httpProxy.createProxyServer({
    secure: !insecureValue
});



proxy.on('proxyRes', function(proxyRes, req, res, options) {
    res.setHeader('Access-Control-Allow-Origin', '*');
开发者ID:hardyoyo,项目名称:angular2-ui-prototype,代码行数:30,代码来源:proxy.ts

示例2:

commander.on('*', (unknownCommand) => {
  commander.outputHelp();
  throw `${yellow(unknownCommand)} is not a known command. You can see all supported commands above.`;
});
开发者ID:Mercateo,项目名称:typedocs,代码行数:4,代码来源:index.ts

示例3: to

  Update all packages to the latest version, with a caret.
  Only update if the update is substantial:

      update-dependency --minimal --regex '.*' ^latest

  Print the log of the above without actually making any changes.

  update-dependency --dry-run --minimal --regex '.*' ^latest

  Update all packages starting with '@jupyterlab/' to the version
  the 'latest' tag currently points to, with a caret range:

      update-dependency --regex '^@jupyterlab/' ^latest

  Update all packages starting with '@jupyterlab/' in all lerna
  workspaces and the root package.json to whatever version the 'next'
  tag for each package currently points to (with a caret tag).
  Update the version range only if the change is substantial.

      update-dependency --lerna --regex --minimal '^@jupyterlab/' ^next
`);
});

commander.parse(process.argv);

// If no arguments supplied
if (!process.argv.slice(2).length) {
  commander.outputHelp();
  process.exit(1);
}
开发者ID:vidartf,项目名称:jupyterlab,代码行数:30,代码来源:update-dependency.ts

示例4: handleCommand

    .option('--loader-csv', '[Loader/CSV] Enable the CSV loader')
    .option('--loader-csv-path <path>', '[Loader/CSV] The path to the CSV file containing the URLs to be tested')

    // replacers
    .option('--replacer-static', '[Replacer/Static] Enable the static replacer')
    .option('--replacer-static-replace <replace>', '[Replacer/Static] The string to replace in each URL being tested')
    .option('--replacer-static-with <with>', '[Replacer/Static] The value to replace each match of the URLs being tested')

    .action(async () => {
        const config: TestSuiteConfig = TestSuiteConfigFactory.fromCommanderOptions(execCmd.opts()) as any;
        await handleCommand(config);

    });

if (!process.argv.slice(2).length) {
    sireg.outputHelp();
}
sireg.parse(process.argv);

async function handleCommand(config: TestSuiteConfig): Promise<void> {
    try {
        await siregExec(config);
    } catch (e) {
        if (e instanceof SiregError) {
            winston.error(`${e.message}`);
        } else {
            winston.error(`Unexpected critical error occucured. Stack trace:\n ${e.stack}`);
        }
        process.exit(1);
    }
}
开发者ID:,项目名称:,代码行数:31,代码来源:

示例5:

program.command('*').action(() => {
    console.log('Unknown command');
    program.outputHelp();
    process.exit(1);
});
开发者ID:thomas-hilaire,项目名称:spews-importer,代码行数:5,代码来源:importer.ts

示例6:

 let outputHelp = () => {
   program.outputHelp()
   process.exit(1);
 }
开发者ID:bitsmag,项目名称:angular2-dependencies-graph,代码行数:4,代码来源:application.ts

示例7: BSTVirtualAlexa

    .action(function () {
        // Just by casting program to options, we can get all the options which are set on it
        const options: any = program;
        let url = options.url;
        const interactionModel = options.model;
        const intentSchemaPath = options.intents;
        const samplesPath = options.samples;
        const applicationID = options.appId;
        const locale = options.locale;
        const userId = options.userId;

        if (process.argv.some( arg => arg === "-h" || arg === "--help")) {
            program.outputHelp();
            process.exit(0);
            return;
        }

        if (!options.url) {
            const proxyProcess = Global.running();
            if (proxyProcess === null) {
                console.error("No URL specified and no proxy is currently running");
                console.log();
                console.log("URL (--url) must be specified if no proxy is currently running");
                console.log();
                console.log("If a proxy is running, the launch request will automatically be sent to it");
                console.log();
                process.exit(0);
                return;
            }

            url = "http://localhost:" + proxyProcess.port;
        }

        const savedSession = Global.config().loadSession() || {};
        const localeToUse = locale ? locale : savedSession.locale;
        const userIdToUse = userId ? userId : savedSession.userId;

        const speaker = new BSTVirtualAlexa(url, interactionModel, intentSchemaPath, samplesPath, applicationID, localeToUse, userIdToUse);
        try {
            speaker.start(true);
        } catch (error) {
            process.exit(0);
            return;
        }

        if (userIdToUse) {
            speaker.context().user().setID(userIdToUse);
        }

        if (options.accessToken) {
            speaker.context().setAccessToken(options.accessToken);
        }

        speaker.launched(function (errorInLaunch: any, response: any, request: any) {
            if (errorInLaunch) {
                console.error(chalk.red("Error: " + errorInLaunch));
                return;
            }

            const jsonPretty = JSON.stringify(response, null, 4);
            console.log("Request:");
            console.log(chalk.hex(LoggingHelper.REQUEST_COLOR)(JSON.stringify(request, null, 4)));
            console.log("");
            console.log("Response:");
            console.log(chalk.cyan(jsonPretty));
            console.log("");
        });
    });
开发者ID:bespoken,项目名称:bst,代码行数:68,代码来源:bst-launch.ts

示例8: device

    () => {
        program
            .usage("[options] <utterance>")
            .option("-l, --locale <locale>", "The locale to use for the virtual device (en-US, en-GB, de-DE, etc.)")
            .option("-t, --token <token>", `The token for interacting with your virtual device - get it here:

        \thttps://${Global.SpokesDashboardHost}/skills/${Global.config().sourceID()}/validation
        \t(Bespoken Dashboard account required for use of this feature)\n`)
            .option("-v, --voiceID <voiceID>", "The AWS Polly voice ID to use for generating speech")
            .description("Speaks to your virtual Alexa device")
            .action(async function () {
                // To handle utterances with multiple words, we need to look at the args
                let utterance: string = "";
                for (let i = 0; i < program.args.length; i++ ) {
                    let arg = program.args[i];
                    if (typeof arg !== "string") {
                        break;
                    }

                    if (utterance.length > 0) {
                        utterance += " ";
                    }
                    utterance += arg;
                }

                // Just by casting program to options, we can get all the options which are set on it
                const options: any = program;
                const token = options.token;
                const locale = options.locale;
                const voiceID = options.voiceID;

                let virtualDeviceResponse;
                try {
                    virtualDeviceResponse = await VirtualDeviceClient.speak(utterance, token, locale, voiceID);
                } catch (ex) {
                    if (ex.message === "Token Required") {
                        console.log("You need a token for this option to work, get it here:");
                        console.log();
                        console.log("\thttps://" + Global.SpokesDashboardHost + "/skills/" + Global.config().sourceID() + "/validation");
                        console.log("\t(Bespoken Dashboard account required for use of this feature)");
                        console.log();
                        console.log("Then try again with:");
                        console.log();
                        console.log("\tbst speak --token <ProvidedToken> <Speech to try>");
                        console.log();

                    } else {
                        let displayMessage = getError(ex);
                        // Error is comming from virtual device sdk, we output it
                        const Logger = "BST";
                        console.log(displayMessage);
                        LoggingHelper.prepareForFileLoggingAndDisableConsole("bst-debug.log");
                        LoggingHelper.error(Logger, "Error using bst version: " + Global.version() + " on Node: " + process.version);
                        LoggingHelper.error(Logger, ex);
                    }
                    process.exit(0);
                    return;
                }

                if (token) {
                    console.log("Your token is saved, you can now use this command without providing a token");
                }
                let nodeId = undefined;
                if (Global.config() && Global.config().secretKey && Global.config().secretKey()) {
                    nodeId = Global.config().secretKey();
                }
                BstStatistics.instance().record(BstCommand.speak, undefined, nodeId, Global.version());
                console.log(VirtualDeviceClient.renderResult(virtualDeviceResponse));
            });


        // Forces help to be printed
        if (process.argv.slice(2).length === 0) {
            program.outputHelp();
        } else {
            program.parse(process.argv);
        }
    }
开发者ID:bespoken,项目名称:bst,代码行数:78,代码来源:bst-speak.ts


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