當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript yargs.command函數代碼示例

本文整理匯總了TypeScript中yargs.command函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript command函數的具體用法?TypeScript command怎麽用?TypeScript command使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了command函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: installCommands

export function installCommands() {
  const plugins = _(npmPaths())
    .filter(existsSync)
    .map(listPluggings)
    .flatten()
    .uniq()
    .value() as string[]

  let yargs = require('yargs')
  const processedCommands = {}
  for (const moduleName of ['./cmds', ...plugins]) {
    try {
      const cmdModule = require(moduleName)
      const cmdModules = Array.isArray(cmdModule) ? cmdModule : [cmdModule]
      for (const cmd of cmdModules) {
        const commandName = cmd.command.split(' ')[0]
        if (!processedCommands[commandName]) {
          yargs = yargs.command(wrapCommand(cmd))
          processedCommands[commandName] = moduleName
        } else {
          if (processedCommands[commandName] === './cmds') {
            console.warn(`${chalk.yellow(
              `warning`,
            )} command ${commandName} both exists in plugin ${moduleName} and is shipped with the graphql-cli.
The plugin is being ignored.`)
          }
        }
      }
    } catch (e) {
      console.log(`Can't load ${moduleName} plugin:` + e.stack)
    }
  }
  return yargs
}
開發者ID:koddsson,項目名稱:graphql-cli,代碼行數:34,代碼來源:index.ts

示例2:

function Argv$commandObject() {
    let ya = yargs
        .command("commandname", "description", {
            arg: ({
                alias: "string",
                array: true,
                boolean: true,
                choices: [undefined, false, "a", "b", "c"],
                coerce: f => JSON.stringify(f),
                config: true,
                configParser: t => JSON.parse(fs.readFileSync(t, "utf8")),
                count: true,
                default: "myvalue",
                defaultDescription: "description",
                demand: true,
                demandOption: true,
                desc: "desc",
                describe: "describe",
                description: "description",
                global: false,
                group: "group",
                nargs: 1,
                normalize: false,
                number: true,
                requiresArg: true,
                skipValidation: false,
                string: true,
                type: "string"
            } as yargs.Options)
        });
}
開發者ID:markusmauch,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:yargs-tests.ts

示例3:

function Argv$commandObject() {
    var ya = yargs
        .command("commandname", "description", {
            "arg": {
                alias: "string",
                array: true,
                boolean: true,
                choices: ["a", "b", "c"],
                coerce: f => JSON.stringify(f),
                config: true,
                configParser: t => t,
                count: true,
                default: "myvalue",
                defaultDescription: "description",
                demand: true,
                desc: "desc",
                describe: "describe",
                description: "description",
                global: false,
                group: "group",
                nargs: 1,
                normalize: false,
                number: true,
                requiresArg: true,
                skipValidation: false,
                string: true,
                type: "string"
            }
        })
}
開發者ID:longlho,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:yargs-tests.ts

示例4: command

function command() {
    let argv = yargs
        .usage('npm <command>')
        .command('install', 'tis a mighty fine package to install')
        .command('publish', 'shiver me timbers, should you be sharing all that', yargs =>
            yargs.option('f', {
                alias: 'force',
                description: 'yar, it usually be a bad idea'
            })
                .help('help')
        )
        .command("build", "arghh, build it mate", {
            tag: {
                default: true,
                demand: true,
                description: "Tag the build, mate!"
            },
            publish: {
                default: false,
                description: "Should i publish?"
            }
        })
        .command({
            command: "test",
            describe: "test package",
            builder: {
                mateys: {
                    demand: false
                }
            },
            handler: (args: any) => {
                /* handle me mateys! */
            }
        })
        .command("test", "test mateys", {
            handler: (args: any) => {
                /* handle me mateys! */
            }
        })
        .help('help')
        .argv;

    yargs
        .command('get', 'make a get HTTP request', (yargs) => {
            return yargs.option('url', {
                alias: 'u',
                default: 'http://yargs.js.org/'
            });
        })
        .help()
        .argv;

    yargs
        .command(
        'get',
        'make a get HTTP request',
        (yargs) => {
            return yargs.option('u', {
                alias: 'url',
                describe: 'the URL to make an HTTP request to'
            });
        },
        (argv) => {
            console.dir(argv.url);
        }
        )
        .help()
        .argv;
}
開發者ID:markusmauch,項目名稱:DefinitelyTyped,代碼行數:69,代碼來源:yargs-tests.ts

示例5:

const versionsIeOption: yargs.Options = {
  describe: 'The ie driver version.',
  type: 'string'
};
const VERSIONS_STANDALONE = 'versions.standalone';
const versionsStandaloneOption: yargs.Options = {
  describe: 'The selenium server standalone version.',
  type: 'string'
};

// tslint:disable-next-line:no-unused-expression
yargs
    .command(
        'clean', 'Removes downloaded files from the out_dir.',
        (yargs: yargs.Argv) => {
          return yargs.option(LOG_LEVEL, logLevelOption)
              .option(OUT_DIR, outDirOption);
        },
        (argv: yargs.Arguments) => {
          clean.handler(argv);
        })
    .command(
        'shutdown', 'Shutdown a local selenium server with GET request',
        (yargs: yargs.Argv) => {
          return yargs.option(LOG_LEVEL, logLevelOption);
        },
        (argv: yargs.Arguments) => {
          shutdown.handler(argv);
        })
    .command(
        'start', 'Start up the selenium server.',
        (yargs: yargs.Argv) => {
開發者ID:angular,項目名稱:webdriver-manager,代碼行數:32,代碼來源:index.ts

示例6: wrap

import chalk from "chalk"
import { getElectronVersion } from "electron-builder-lib/out/util/electronVersion"
import { getGypEnv } from "electron-builder-lib/out/util/yarn"
import { readJson } from "fs-extra-p"
import isCi from "is-ci"
import * as path from "path"
import { loadEnv } from "read-config-file"
import updateNotifier from "update-notifier"
import yargs from "yargs"
import { build, configureBuildCommand } from "../builder"
import { createSelfSignedCert } from "./create-self-signed-cert"
import { configureInstallAppDepsCommand, installAppDeps } from "./install-app-deps"
import { start } from "./start"

// tslint:disable:no-unused-expression
yargs
  .command(["build", "*"], "Build", configureBuildCommand, wrap(build))
  .command("install-app-deps", "Install app deps", configureInstallAppDepsCommand, wrap(installAppDeps))
  .command("node-gyp-rebuild", "Rebuild own native code", configureInstallAppDepsCommand /* yes, args the same as for install app deps */, wrap(rebuildAppNativeCode))
  .command("create-self-signed-cert", "Create self-signed code signing cert for Windows apps",
    yargs => yargs
      .option("publisher", {
        alias: ["p"],
        type: "string",
        requiresArg: true,
        description: "The publisher name",
      })
      .demandOption("publisher"),
    wrap(argv => createSelfSignedCert(argv.publisher)))
  .command("start", "Run application in a development mode using electron-webpack",
    yargs => yargs,
    wrap(argv => start()))
開發者ID:ledinhphuong,項目名稱:electron-builder,代碼行數:32,代碼來源:cli.ts

示例7: loadFactory

				main: mainFile
			})
		}

		console.log('Completed!')
		process.exit(0)
	})
}

export function loadFactory(spec: string) {
	let converterFactory: ConverterFactory = require(spec)
	if (typeof (converterFactory as any).default !== 'undefined') {
		converterFactory = (converterFactory as any).default
	}

	return converterFactory
}

function defer<T extends Function>(fn: T) {
	return (...args: any[]) => {
		setTimeout(fn.bind(null, ...args), 0)
	}
}

yargs
	.command(ReflectCommand)
	.command(GenerateCommand)
	.strict()
	.recommendCommands()
	.demandCommand().argv
開發者ID:docscript,項目名稱:docscript,代碼行數:30,代碼來源:cli.ts

示例8: inject

  process.exit(1);
};

let failIfUnsuccessful = (success: boolean) => {
  if (!success) {
    process.exit(1);
  }
};

yargsModule.command(['assist', '*'], 'Watches for file changes and outputs current errors and violations', {
  port: {
    describe: 'the port to have the status server listen on'
  }
}, (yargs) => {
  if (yargs._.length === 0 || yargs._.length === 1 && yargs._[0] === 'assist') {
    inject(createAssistCommand).execute({
      statusServerPort: parseInt(yargs.port as string, 10) || 0
    });
  } else {
    console.error('Unknown command');
    process.exit(1);
  }
});

yargsModule.command(['lint'], 'Lints', {}, yargs => {
  inject(createLintCommand).execute().then(onSuccess, onFailure);
});

yargsModule.command(['fix', 'f'], 'Formats changed files and applies tslint fixes', {}, (yargs) => {
  inject(createFixCommand).execute().then(onSuccess, onFailure);
});
開發者ID:AFASSoftware,項目名稱:typescript-assistant,代碼行數:31,代碼來源:index.ts

示例9:

function Argv$commandArray() {
    let ya = yargs
        .command(['commandName', 'commandAlias'], 'command description')
        .argv;
}
開發者ID:Crevil,項目名稱:DefinitelyTyped,代碼行數:5,代碼來源:yargs-tests.ts


注:本文中的yargs.command函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。