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


TypeScript yargs.help函數代碼示例

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


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

示例1:

function Argv$helpDescriptionExplicit() {
    let ya = yargs
        .help('help', 'description', true)
        .argv;
}
開發者ID:markusmauch,項目名稱:DefinitelyTyped,代碼行數:5,代碼來源:yargs-tests.ts

示例2: require

const performanceXServer = require('./performance-experiment/server');
import * as Printer from './printer';
import * as randomPort from './random-port';
import {Results} from './types/types';
const yargs = require('yargs');
const opn = require('opn');
const updateNotifier = require('update-notifier');
const pkg = require('../package.json');

updateNotifier({pkg}).notify(); // Tell user if there's a newer version of LH.

interface LighthouseError extends Error {
  code?: string
};

const cliFlags = yargs
  .help('help')
  .version(() => pkg.version)
  .showHelpOnFail(false, 'Specify --help for available options')

  .usage('$0 url')

  // List of options
  .group([
    'verbose',
    'quiet'
  ], 'Logging:')
  .describe({
    verbose: 'Displays verbose logging',
    quiet: 'Displays no progress, debug logs or errors'
  })
開發者ID:CondeNast,項目名稱:lighthouse,代碼行數:31,代碼來源:bin.ts

示例3:

import * as yargs from 'yargs';
import * as Contracts from './contracts';

export default yargs
    .help('help', 'Show help.')
    .version(() => {
        return `Current version: ${require('../package.json').version}.`;
    })
    .option('config', {
        alias: 'c',
        describe: 'Path to config file.',
        type: 'string'
    })
    .option('backup', {
        alias: 'b',
        describe: 'Make backup before cleanup.',
        default: undefined,
        type: 'boolean'
    })
    .argv as Contracts.Arguments;
開發者ID:QuatroCode,項目名稱:cleanup-package-json,代碼行數:20,代碼來源:arguments.ts

示例4:

import * as yargs from 'yargs';

export interface ArgOptions {
    append?: string;
    out?: string;
    configJson?: string;
    baseDir?: string;
}

export default yargs
    .help("help", "Show help")
    .version(() => {
        return `Current version: ${require('../package.json').version}`;
    })
    .option('append', {
        describe: 'Append files to global',
        type: "string"
    })
    .option("out", {
        describe: "dts-bundle bundled out file",
        type: "string"
    })
    .option("configJson", {
        describe: "dts-bundle configuration file",
        default: "dts-bundle.json",
        type: "string"
    })
    .option("baseDir", {
        describe: "dts-bundle base directory",
        type: "string"
    })
開發者ID:QuatroCode,項目名稱:dts-bundle-append,代碼行數:31,代碼來源:arguments.ts

示例5:

import {GsdApp} from './app/gsd';
import {QueryApp} from './app/query';
import * as Fs from 'fs';
import * as yargs from 'yargs';

[GsdApp, QueryApp].forEach(x => x.setupArgv(yargs));

yargs
  .help()
  .version(require('../package.json').version)
  .demand(1, 'must provide a valid command')
  .argv;
開發者ID:SIXNetworks,項目名稱:withSIX-GSD,代碼行數:12,代碼來源:runner.ts

示例6: function

(function() {
	let command = argv._[0];
	if (command === 'enrichment') {
		if (argv.input) {
			fs.readFile(argv.input, 'utf8', function (err, raw_data) {
				if (err) {
					process.stderr.write(`Could not open file: ${argv.input}\n`);
					return;
				}
				let data = raw_data.split('\n');
				data = data.map((d) => { return d.replace('\r', ''); }); 
				console.log('=> Running cluster enrichment analysis...');
				clusterEnrichment.run(data, argv.type, (result) => {
					if (argv.output) {
						fs.writeFile(argv.output, JSON.stringify(result, null, 2), (err) => {
							if (err) {
								process.stdout.write(`\x1b[31m=> Could not write to file ${argv.output}. \x1b[0m \n`);
							}
							else {
								console.log('=> Output written to file.');
							}
						});
					}
					if (argv.sort) {
						console.log(`=> Sorting by: ${argv.sort}`);
						try {
							let sort_key = argv.sort.split('.'),
								stage = _.indexOf(clusterEnrichment.clusterToStage, sort_key[0]);
							if (stage === -1) {
								throw new Error(`Not a valid cluster: ${sort_key}`);
							}
							sort_key[0] = 'data[' + stage + ']';
							result = utils.sort(result, sort_key.join('.'));
							utils.tabulate(result, ['label', sort_key.join('.')], console.log);
						}
						catch (e) {
							process.stdout.write(`\x1b[31m=> Sort failed: ${e.message}. \x1b[0m \n`);
						}
					}
					
					console.log('=> Done.');
				});			
			});
		}
		else if (argv.disease || argv.kegg) {
			console.log('=> Running cluster enrichment analysis...');
			let input = [argv.disease || argv.kegg],
				type = (argv.disease ? 'disease' : 'kegg');
			clusterEnrichment.run(input, type, (result) => {
				if (result.length == 0) {
					console.log('=> Done.');
					return;
				}
				if (argv.output) {
					fs.writeFile(argv.output, JSON.stringify(result, null, 2), (err) => {
						if (err) {
							process.stdout.write(`\x1b[31m=> Could not write to file ${argv.output}. \x1b[0m \n`);
						}
						else {
							console.log('=> Output written to file.');
							console.log('=> Done.');
						}
					});
				}
				else {
					utils.tabulate(result, clusterEnrichment.clusterToStage.map(function(stage) { return 'data[' }), console.log);
					console.log('=> Done.');
				}				
			});
		}
		else {
			console.log(yargs.help());
		}
	}
  else if (command === 'filter') {
    if (argv.input === undefined) {
      process.stderr.write(`Input file required.`);
      return;
    }
    if (argv.output === undefined) {
      process.stderr.write(`Output file required.`);
      return;
    }
    fs.readFile(argv.input, 'utf8', function (err, raw_data) {
      if (err) {
        process.stderr.write(`Could not open file: ${argv.input}\n`);
        return;
      }
      console.log('=> Running filter...');
      let input_list = raw_data.split('\n');
      input_list = input_list.map((d) => { return d.replace('\r', ''); });
      Filter.valid(input_list, (result) => {
        result = result.filter((d) => { return d; });
        console.log(`Filtered ${input_list.length-result.length}/${input_list.length} input genes`);
        let res_string = result.join('\n');
        fs.writeFile(argv.output, res_string, (err) => {
          if (err) {
            process.stdout.write(`\x1b[31m=> Could not write to file ${argv.output}. \x1b[0m \n`);
          }
          else {
//.........這裏部分代碼省略.........
開發者ID:delosh653,項目名稱:SemNExT-Visualizations,代碼行數:101,代碼來源:main.ts

示例7: require

  console.warn('Compatibility error', 'Lighthouse requires node 5+ or 4 with --harmony');
  process.exit(_RUNTIME_ERROR_CODE);
}

import * as path from 'path';
const yargs = require('yargs');
import * as Printer from './printer';
const lighthouse = require('../lighthouse-core');
const assetSaver = require('../lighthouse-core/lib/asset-saver.js');
const log = require('../lighthouse-core/lib/log');
import {ChromeLauncher} from './chrome-launcher';
import * as Commands from './commands/commands';

const perfOnlyConfig = require('../lighthouse-core/config/perf.json');

const cli = yargs
  .help('help')
  .version(() => require('../package').version)
  .showHelpOnFail(false, 'Specify --help for available options')

  .usage('$0 url')

  // List of options
  .group([
    'verbose',
    'quiet'
  ], 'Logging:')
  .describe({
    verbose: 'Displays verbose logging',
    quiet: 'Displays no progress or debug logs'
  })
開發者ID:vigneshshanmugam,項目名稱:lighthouse,代碼行數:31,代碼來源:bin.ts


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