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


TypeScript commandpost.create函數代碼示例

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


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

示例1:

{
	replace: boolean;
	baseDir: string[];
	formattersDir: string[];
	dryRun: boolean;
	tslint: boolean;
	tslintRulesDir: string[];
	verbose: boolean;
}

interface RootArguments
{
	files: string[];
}

let root = commandpost
	.create<RootOptions, RootArguments>("ts-cfmt [files...]")
	.version(packageJson.version, "-v, --version")
	.option("-r, --replace", "replace .ts file")
	.option("--baseDir <path>", "config file lookup from <path>")
	.option("--formattersDir <path>", "formatters to use are looked up in <path>", "./formatters")
	.option("--no-tslint", "don't read a tslint.json")
	.option("--tslintRulesDir <path>", "tslint rules to use are looked up in <path>")
	.option("--dryRun", "outputs the changes to console")
	.option("--verbose", "makes output more verbose")
	.action((opts, args) =>
	{
		const replace = !!opts.replace;
		const baseDir = opts.baseDir ? opts.baseDir[0] : null;
		const formattersDir = opts.formattersDir ? opts.formattersDir[0] : null;
		const dryRun = !!opts.dryRun;
		const tslint = !!opts.tslint;
開發者ID:yaroslav0507,項目名稱:CodeFormatter,代碼行數:32,代碼來源:Cli.ts

示例2:

    packageVersion: pkg.version
});
if (notifier.update) {
    notifier.notify();
}

let packageJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, "../package.json"), "utf8"));

import * as commandpost from "commandpost";

interface RootOpts {
    reviewfile: string[];
    base: string[];
}

let root = commandpost
    .create<RootOpts, {}>("reviewjs")
    .version(packageJson.version, "-v, --version")
    .option("--reviewfile <file>", "where is ReVIEWconfig.js?")
    .option("--base <path>", "alternative base path")
    .action(() => {
        process.stdout.write(root.helpText() + '\n');
    });

interface CompileOpts {
    ast: boolean;
    target: string[];
}

interface CompileArgs {
    document: string;
}
開發者ID:vvakame,項目名稱:review.js,代碼行數:32,代碼來源:cli.ts

示例3:

"use strict";

import * as lib from "./index";

import * as fs from "fs";
let packageJson = JSON.parse(fs.readFileSync(__dirname + "/../package.json", "utf8"));
import * as commandpost from "commandpost";

interface RootOpts {
    word: string[];
}

let root = commandpost
    .create<RootOpts, {}>("tssample")
    .version(packageJson.version, "-v, --version")
    .option("--word <word>", "hi! <word>")
    .action((opts, args) => {
        process.stdout.write(lib.hi(opts.word[0]) + "\n");
        process.exit(0);
    });

commandpost.exec(root, process.argv);
開發者ID:HansS,項目名稱:typescript-project-sample-vvakame,代碼行數:22,代碼來源:cli.ts

示例4: require

import * as commandpost from "commandpost";
import * as YAML from "js-yaml";
import { convert } from "./converter";

const pkg = require("../package.json");

interface RootOptions {
  /** @deprecated */
  stdin: boolean;
  output: string[];
  namespace: string[];
  withQuery: boolean;
  sortProps: boolean;
}

const root = commandpost
  .create<RootOptions, { input_filename: string }>("sw2dts [input_filename]")
  .version(pkg.version, "-v, --version")
  .option("-w, --with-query", "With GET query parameters.")
  .option("-s, --sort-props", "Sort type properties order.")
  .option("-o, --output <output_filename>", "Output to file.")
  .option("-n, --namespace <namespace>", "Use namespace.")
  .option("--stdin", "[Deprecated] Input from standard input.")
  .action(async (opts, args) => {
    // TODO Delete '--stdin' option.
    if (opts.stdin) {
      console.warn("'--stdin' option is deprecated.");
    }
    if (args.input_filename && opts.stdin) {
      process.stderr.write("Invalid parameters!\n");
      process.exit(1);
      return;
開發者ID:mstssk,項目名稱:sw2dts,代碼行數:32,代碼來源:cli.ts

示例5: require

import htmlconv from './main';

interface RootOptions {
  encoding: string[];
  out: string[];
  patterns: string[];
  patternsText: string[];
  text: string[];
}

interface RootArgs {
  inputPath: string;
}

const pkg = require('../package.json');
const root = commandpost
  .create<RootOptions, RootArgs>('cw-htmlconv [inputPath]')
  .version(pkg.version, '-v, --version')
  .option('-o, --out [path]', 'Output to single file')
  .option('-p, --patterns [path]', 'JSON file of Definition for convert patterns')
  .option('-t, --text [html]', 'Raw HTML text that want to convert')
  .option('-v, --version', 'Print version')
  .option('--patterns-text [text]', 'JSON Definition for convert patterns')
  .action((opts, args, rest) => {
    // for Debug
    //console.log(opts, args, rest);

    const textPromise     = text(opts, args);
    const patternsPromise = patterns(opts);

    Promise.all([textPromise, patternsPromise])
      .then((values: any[]) => {
開發者ID:crescware,項目名稱:cw-htmlconv,代碼行數:32,代碼來源:cli.ts

示例6: setup

import * as dtsm from "./";
import * as pmb from "packagemanager-backend";
import * as is from "./incrementalsearch";

import * as commandpost from "commandpost";
import * as archy from "archy";

interface RootOptions {
    offline: boolean;
    config: string[];
    remote: string[];
    insight: string[];
    ref: string[];
}

let root = commandpost
    .create<RootOptions, {}>("dtsm")
    .version(pkg.version, "-v, --version")
    .option("--insight <use>", "send usage opt in/out. in = `--insight true`, out = `--insight false`")
    .option("--offline", "offline first")
    .option("--remote <uri>", "uri of remote repository")
    .option("--config <path>", "path to json file")
    .option("--ref <ref>", "ref of repository")
    .action(() => {
        process.stdout.write(root.helpText() + '\n');
    });

root
    .subCommand("init")
    .description("make new dtsm.json")
    .action(() => {
        setup(root.parsedOpts)
開發者ID:ukyo,項目名稱:dtsm,代碼行數:32,代碼來源:cli.ts

示例7:

import * as commandpost from "commandpost";

interface RootOptions {
    templateHtml?: string[];
    templateFile?: string[];
    componentFile?: string[];
    componentName?: string[];
    originUrl?: string[];
    baseUrl?: string[];
    reqUrl?: string[];
    outFile?: string[];
    preboot?: boolean;
}

let root = commandpost
    .create<RootOptions, {}>("ngssr")
    .version(pkg.version, "-v, --version")
    .usage(`ngssr --templateHtml "<app></app>" --componentFile ./example/app.component.js --componentName AppComponent`)
    .option("--templateHtml <templateHtml>", "string oftemplate html")
    .option("--templateFile <templateFile>", "path to template html file")
    .option("--componentFile <componentFile>", "path to component js file")
    .option("--componentName <componentName>", "component class name")
    .option("--originUrl <originUrl>", "specify origin url", "http://localhost:8080")
    .option("--baseUrl <baseUrl>", "specify base url", "/")
    .option("--reqUrl <reqUrl>", "specify request url", "/")
    .option("--outFile <outFile>", "output file of generated html")
    .option("--preboot", "turn on generating preboot code", false)
    .action(opts => {
        let templateFile = opts.templateFile[0] || "";
        let templateHtml = opts.templateHtml[0] || "";
        let componentFile = opts.componentFile[0] || "";
開發者ID:gdi2290,項目名稱:ng-ssr-cli,代碼行數:31,代碼來源:cli.ts

示例8:

interface RootOpts {
    rulesJson: boolean;
    rulesYaml: boolean;
    replace: boolean;
    verify: boolean;
    stdout: boolean;
    diff: boolean;
    verbose: boolean;
    rules: string[];
}

interface RootArgs {
    files: string[];
}

const root = commandpost
    .create<RootOpts, RootArgs>("prh [files...]")
    .version(pkg.version, "-v, --version")
    .option("--rules-json", "emit rule set in json format")
    .option("--rules-yaml", "emit rule set in yaml format")
    .option("--rules <path>", "path to rule yaml file")
    .option("--verify", "checking file validity")
    .option("--stdout", "print replaced content to stdout")
    .option("--diff", "show unified diff")
    .option("--verbose", "makes output more verbose")
    .option("-r, --replace", "replace input files")
    .action((opts, args) => {

        if (opts.rulesJson || opts.rulesYaml) {
            if (opts.verbose) {
                console.warn(`processing ${process.cwd()} dir...`);
            }
開發者ID:vvakame,項目名稱:prh,代碼行數:32,代碼來源:cli.ts


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