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


TypeScript commander.description函数代码示例

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


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

示例1: cli

export function cli(argv: string[], onSuccess: IOnCliSuccess, onError: IOnCliError): IRunningTypespace {
    "use strict";

    program
        .description(metadata.description)
        .version(metadata.version)
        .usage("-n MyProject [-c tsconfig.json] [-o output.ts] [-r path/to/files] [-t none|commonjs]")
        .option("-c --config [path]", "input tsconfig.json file path to load files from (optional)")
        .option("-n --namespace [string]", "name of the root namespace")
        .option("-o --out-file [path]", "output .ts file path (optional)")
        .option("-r --root [string]", "root path to search for files under (optional)")
        .option("-t --target [string]", "module resolution target (optional)")
        .parse(argv);

    const typespace: Typespace = new Typespace(program);
    const conversion: Promise<void> = typespace.convert()
        .then(contents => {
            const outFile: string = program.outFile;
            if (outFile) {
                onSuccess(contents, outFile);
            }
        })
        .catch(onError);

    return { typespace, conversion };
};
开发者ID:JoshuaKGoldberg,项目名称:Typespace,代码行数:26,代码来源:cli.ts

示例2: run

export default function run(): void {
  commander
    .description(`Sucrase: super-fast Babel alternative.`)
    .usage("[options] <srcDir>")
    .option(
      "-d, --out-dir <out>",
      "Compile an input directory of modules into an output directory.",
    )
    .option("--out-extension <extension>", "File extension to use for all output files.", "js")
    .option("--exclude-dirs <paths>", "Names of directories that should not be traversed.")
    .option("-t, --transforms <transforms>", "Comma-separated list of transforms to run.")
    .option("-q, --quiet", "Don't print the names of converted files.")
    .option(
      "--enable-legacy-typescript-module-interop",
      "Use default TypeScript ESM/CJS interop strategy.",
    )
    .option("--enable-legacy-babel5-module-interop", "Use Babel 5 ESM/CJS interop strategy.")
    .option("--jsx-pragma <string>", "Element creation function, defaults to `React.createElement`")
    .option("--jsx-fragment-pragma <string>", "Fragment component, defaults to `React.Fragment`")
    .parse(process.argv);

  if (!commander.outDir) {
    console.error("Out directory is required");
    process.exit(1);
  }

  if (!commander.transforms) {
    console.error("Transforms option is required.");
    process.exit(1);
  }

  if (!commander.args[0]) {
    console.error("Source directory is required.");
    process.exit(1);
  }

  const outDir = commander.outDir;
  const srcDir = commander.args[0];

  const options: CLIOptions = {
    outExtension: commander.outExtension,
    excludeDirs: commander.excludeDirs ? commander.excludeDirs.split(",") : [],
    quiet: commander.quiet,
    sucraseOptions: {
      transforms: commander.transforms.split(","),
      enableLegacyTypeScriptModuleInterop: commander.enableLegacyTypescriptModuleInterop,
      enableLegacyBabel5ModuleInterop: commander.enableLegacyBabel5ModuleInterop,
      jsxPragma: commander.jsxPragma || "React.createElement",
      jsxFragmentPragma: commander.jsxFragmentPragma || "React.Fragment",
    },
  };

  buildDirectory(srcDir, outDir, options).catch((e) => {
    process.exitCode = 1;
    console.error(e);
  });
}
开发者ID:alangpierce,项目名称:sucrase,代码行数:57,代码来源:cli.ts

示例3: main

async function main() {
  const args = commander
    .description(
      `Generate web-based treemaps.

  Reads a series of
    size path
  lines from stdin, splits path on '/' and outputs HTML for a treemap.
`
    )
    .option('-o, --output [path]', 'output to file, not stdout')
    .option('--title [string]', 'title of output HTML')
    .parse(process.argv);
  const node = treeFromLines(await readLines());
  const treemapJS = await readFile(__dirname + '/../webtreemap.js');
  const title = args.title || 'webtreemap';

  let output = `<!doctype html>
<title>${title}</title>
<style>
body {
  font-family: sans-serif;
}
#treemap {
  width: 800px;
  height: 600px;
}
</style>
<div id='treemap'></div>
<script>const data = ${JSON.stringify(node)}</script>
<script>${treemapJS}</script>
<script>webtreemap.render(document.getElementById("treemap"), data, {
  caption: ${humanSizeCaption},
});</script>
`;
  if (args.output) {
    fs.writeFileSync(args.output, output, {encoding: 'utf-8'});
  } else {
    console.log(output);
  }
}
开发者ID:evmar,项目名称:webtreemap,代码行数:41,代码来源:cli.ts

示例4: async

    }
  }

  if (fileLog.length > 0) {
    console.log(packagePath);
    console.log(fileLog.join('\n'));
    console.log();
  }

  // Write the file back to disk.
  if (!dryRun && fileUpdated) {
    utils.writePackageData(packagePath, data);
  }
}

commander
  .description('Update dependency versions')
  .usage('[options] <package> [versionspec], versionspec defaults to ^latest')
  .option('--dry-run', 'Do not perform actions, just print output')
  .option('--regex', 'Package is a regular expression')
  .option('--lerna', 'Update dependencies in all lerna packages')
  .option('--path [path]', 'Path to package or monorepo to update')
  .option('--minimal', 'only update if the change is substantial')
  .arguments('<package> [versionspec]')
  .action(
    async (name: string | RegExp, version: string = '^latest', args: any) => {
      let basePath = path.resolve(args.path || '.');
      let pkg = args.regex ? new RegExp(name) : name;

      if (args.lerna) {
        let paths = utils.getLernaPaths(basePath).sort();
开发者ID:vidartf,项目名称:jupyterlab,代码行数:31,代码来源:update-dependency.ts

示例5: require

#!/usr/bin/env node

import * as commander from 'commander';
import tasks from '../tasks';

const PKG = require('../../package.json');
const {name,version} = PKG;

commander
	.description('Several helpers to create webpack configs or compile/preview files')
	.usage('[options]')

Object.keys(tasks).forEach(function(taskName){
	const task = tasks[taskName];
	const {alias,flags,help} = task;
	const command = commander.command(taskName);
	if(alias){
		command.alias(alias);
	}
	if(help){
		command.description(help);
	}
	if(flags && flags.length){
		flags.forEach(function([f,[desc,def]]){
			command.option(f,desc,def);
		})
	}
});

commander
	.parse(process.argv);
开发者ID:Xananax,项目名称:wpack,代码行数:31,代码来源:wpack.ts

示例6: if

  if (!next && tags.next) {
    cmds.push(`npm dist-tag rm ${pkg} next`);
  } else if (next && next !== tags.next) {
    cmds.push(`npm dist-tag add ${pkg}@${next} next`);
  }

  return cmds;
}

function flatten(a: any[]) {
  return a.reduce((acc, val) => acc.concat(val), []);
}

commander
  .description(
    `Print out commands to update npm 'latest' and 'next' dist-tags
so that 'latest' points to the latest stable release and 'next'
points to the latest prerelease after it.`
  )
  .option('--lerna', 'Update dist-tags in all lerna packages')
  .option('--path [path]', 'Path to package or monorepo to update')
  .action(async (args: any) => {
    let basePath = path.resolve(args.path || '.');
    let cmds: string[][] = [];
    let paths: string[] = [];
    if (args.lerna) {
      paths = utils.getLernaPaths(basePath).sort();
      cmds = await Promise.all(paths.map(handlePackage));
    }
    cmds.push(await handlePackage(basePath));
    let out = flatten(cmds).join('\n');
    if (out) {
开发者ID:AlbertHilb,项目名称:jupyterlab,代码行数:32,代码来源:update-dist-tag.ts

示例7: handleAction

function handleAction(action: (options?: any) => Promise<any>) {
  return (options) => {
    // handle global options
    setLevel(levels[options.parent.logLevel.toUpperCase()]);
    // handle specific action
    info(`run ${cyan(options.name())}...`);
    return action(options)
      .then(() => info(`finished ${cyan(options.name())} ♥`))
      .catch(handleError);
  };
}

// specific setup
switch (project.ws.type) {
  case TYPE.SPA:
    commander.description('We build your SPA!');

    commander
      .command('serve')
      .alias('s')
      .description('serve the project')
      .option('-p, --production', 'serve production build')
      .action(handleAction(serveAction));
    break;
  case TYPE.NODE:
    commander.description('We build your Node module!');
    break;
  case TYPE.BROWSER:
    commander.description('We build your Browser module!');
    break;
}
开发者ID:Mercateo,项目名称:typedocs,代码行数:31,代码来源:index.ts

示例8: list

/**
 * @hidden
 */
export interface ReporterProgramArgs extends commander.CommanderStatic {
    readonly exitNicely?: boolean;
    readonly ignore?: string[];
    readonly reporter?: BuiltinReporters | ReporterName;
}

function list(val: string): string[] {
    return val.split(',');
}

/* eslint-disable no-console */
commander
    .description('Report todos and fixmes from json files or stream')
    .version(require('../../package.json').version)
    .usage('[options] <file ...>')
    .option('-i, --ignore <patterns>', 'add ignore patterns', list, [])
    .option('-r, --reporter [reporter]', 'use reporter (table|json|xml|markdown|vscode|raw) (default: table)', 'table')
    .option('-x, --exit-nicely', 'exit with exit code 0 even if todos/fixmes are found', false)
    .on('--help', function() {
        console.log('  Examples:');
        console.log('');
        console.log('    # Report todos from a specific file');
        console.log('    $ leasot-reporter index.json');
        console.log('');
        console.log('    # Report todos from a glob pattern');
        console.log('    $ leasot-reporter **/*.json');
        console.log('');
        console.log('    # Use the json reporter');
开发者ID:pgilad,项目名称:leasot,代码行数:31,代码来源:leasot-reporter.ts

示例9: parseAssociateParser

}

function parseAssociateParser(val: string, req: ExtensionsDb): ExtensionsDb {
    const data = val.split(',');
    if (data.length === 0 || data.length > 2) {
        throw new TypeError('Incorrectly formatted extension / parser registration. (param: ' + val + ')');
    }
    const parser = data[1] || 'defaultParser';
    const ext = data[0];

    req[ext] = { parserName: parser };
    return req;
}

/* eslint-disable no-console */
commander
    .description(require('../../package.json').description)
    .version(require('../../package.json').version)
    .usage('[options] <file ...>')
    .option(
        '-A, --associate-parser [ext,parser]',
        'associate unknown extensions with bundled parsers (parser optional / default: defaultParser)',
        parseAssociateParser,
        {}
    )
    .option('-i, --ignore <patterns>', 'add ignore patterns', list, [])
    .option('-I, --inline-files', 'parse possible inline files', false)
    .option('-r, --reporter [reporter]', 'use reporter (table|json|xml|markdown|vscode|raw) (default: table)', 'table')
    .option('-S, --skip-unsupported', 'skip unsupported filetypes', false)
    .option('-t, --filetype [filetype]', 'force the filetype to parse. Useful for streams (default: .js)')
    .option('-T, --tags <tags>', 'add additional comment types to find (alongside todo & fixme)', list, [])
    .option('-x, --exit-nicely', 'exit with exit code 0 even if todos/fixmes are found', false)
开发者ID:pgilad,项目名称:leasot,代码行数:32,代码来源:leasot.ts

示例10: require

ďťż#!/usr/bin/env node
//var program: commander.ICommand = require('commander');
var program = require('commander');
import * as breezeref from "breezets";
require("breezets");
var fs = require('fs');
var http = require('http');

var metadataurlValue: string = null;
program
    .description('Generates Typescript typedefinitions for a Breeze data service')
    //.arguments('<metadataurl>', "The URL supplying the Breeze data service metadata")
    .arguments('<metadataurl>')
    .action(function (metadataurl: string)
    {
        metadataurlValue = metadataurl;
    })
    .option('-s, --servicename <servicename>', 'The name of the Breeze data service (used when naming files during code generatios)')
    .option('-u, --url <url>', '')
    .option('-n, --namespace <namespace>', '')
    .option('-p, --proxyname <proxyname>', '')
    .option('-t, --no-typedqueries', '')
    .option('-x, --no-extensions', 'Do not generate the breezeextensions.ts library file')
    .action(function (file: any)
    {
        if (!metadataurlValue)
            program.help();
        var serviceurl = program["url"];
        var proxyname = program["proxyname"];

        console.log('metadataurl: %s', metadataurlValue);
开发者ID:tschaumburg,项目名称:BreezeTypedefExtractor,代码行数:31,代码来源:app.ts


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