本文整理汇总了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;
示例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;
}
示例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);
示例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;
示例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[]) => {
示例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)
示例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] || "";
示例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...`);
}