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


TypeScript yargs類代碼示例

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


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

示例1: yargs

export = (argv) => yargs(argv)
	.usage(i18n('Usage: $0 <command> [globs...] [<options>]'))
	.command({
		builder,
		command: 'check [globs...]',
		describe: i18n('Validate that file(s) adhere to .editorconfig settings'),
		handler: check,
	})
	.command({
		builder: (fixArgv) => (
			builder(fixArgv).option('dest', {
				alias: 'd',
				describe: i18n('Destination folder to pipe source files'),
				type: 'string',
			})
		),
		command: 'fix   [globs...]',
		describe: i18n('Fix formatting errors that disobey .editorconfig settings'),
		handler: fix,
	})
	.command({
		builder: inferBuilder,
		command: 'infer [globs...]',
		describe: i18n('Infer .editorconfig settings from one or more files'),
		handler: infer,
	})
	.demandCommand(1, 1, i18n('CommandError: Missing required sub-command.'))
	.help()
	.version(pkg.version)
	.argv;
開發者ID:jedmao,項目名稱:eclint,代碼行數:30,代碼來源:cli.ts

示例2: convert

    convert(target: string, collectionId: string): Record {

        const content = this.prepare(target);
        const args = yargs([content]);

        const url = this.parseUrl(args);
        const headers = this.parseHeaders(args);
        const body = this.parseBody(args, headers);
        const method = this.parseMethod(args, body);

        return RecordService.fromDto({
            id: StringUtil.generateUID(),
            collectionId,
            category: RecordCategory.record,
            name: url,
            parameterType: ParameterType.ManyToMany,
            method,
            body,
            headers,
            url
        });
    }
開發者ID:winken168,項目名稱:Hitchhiker,代碼行數:22,代碼來源:curl_import.ts

示例3: Argv_parsing

function Argv_parsing() {
    let argv1 = yargs.argv;
    let argv2 = yargs(['-x', '1', '-y', '2']).argv;
    let argv3 = yargs.parse(['-x', '1', '-y', '2']);
    console.log(argv1.x, argv2.x, argv3.x);
}
開發者ID:markusmauch,項目名稱:DefinitelyTyped,代碼行數:6,代碼來源:yargs-tests.ts

示例4: constructFilename

import {
    makeApplicationUrn,
    MessageSecurityMode,
    nodesets,
    OPCUAServer,
    SecurityPolicy,
    ServerSession
} from "node-opcua";

Error.stackTraceLimit = Infinity;

function constructFilename(filename: string): string {
    return path.join(__dirname, "../", filename);
}

const argv = yargs(process.argv)
.wrap(132)

  .option("alternateHostname", {
      alias: "a",
      describe: "alternateHostname"
  })

  .option("port", {
      alias: "p",
      default: 26543
  })

  .option("silent", {
      alias: "s",
      default: false,
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:31,代碼來源:simple_secure_server.ts

示例5: require

import * as fs from 'fs';
import * as path from 'path';
const ncu = require('npm-check-updates');
import * as semver from 'semver';
import * as yargs from 'yargs';
import {loadFrameworkVersionInformation, determineInstalledVersions, FrameworkVersionInformation, FrameworkVersionInformationStatic, FrameworkVersionInformationDynamic, FrameworkVersionInformationError,
    PackageVersionInformation, PackageVersionInformationValid, PackageVersionInformationErrorUnknownPackage, PackageVersionInformationErrorNoPackageJSONLock, PackageVersionInformationResult} from './common';

let args = yargs(process.argv)
    .usage("$0 --updade true|false")
    .default('update', 'true')
    .boolean('update').argv;

let updatePackages = args.update;

async function ncuReportsUpdatedVersion(packageVersionInfo: PackageVersionInformationResult) {
    let ncuInfo = await ncu.run({
        packageFile: path.resolve('..', 'frameworks', packageVersionInfo.framework.keyedType, packageVersionInfo.framework.directory, 'package.json'),
        silent: true,
        jsonUpgraded: true,
        loglevel: 'silent'
    });
    if (ncuInfo) {
        return packageVersionInfo.versions.filter((pi: PackageVersionInformationValid) => ncuInfo[pi.packageName])
            .some((pi: PackageVersionInformationValid) => {
                let newVersion = ncuInfo[pi.packageName];
                if (newVersion.startsWith('^')) newVersion = newVersion.substring(1);
                if ( newVersion.startsWith('~')) newVersion = newVersion.substring(1);
                if (newVersion) {
                    return !semver.satisfies(newVersion, '~'+pi.version);
                } else {
開發者ID:localvoid,項目名稱:js-framework-benchmark,代碼行數:31,代碼來源:updateFrameworks.ts


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