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


TypeScript command-line-args.default函数代码示例

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


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

示例1: express



const app: Application = express();

app.use(cookieParser());
app.use(retrieveUserIdFromRequest);
app.use(bodyParser.json());


const commandLineArgs = require('command-line-args');

const optionDefinitions = [
    { name: 'secure', type: Boolean,  defaultOption: true },
];

const options = commandLineArgs(optionDefinitions);

// REST API
app.route('/api/lessons')
    .get(checkIfAuthenticated,
        _.partial(checkIfAuthorized,['STUDENT']),
        readAllLessons);

app.route('/api/admin')
    .post(checkIfAuthenticated,
        _.partial(checkIfAuthorized,['ADMIN']),
        loginAsUser);

app.route('/api/signup')
    .post(createUser);
开发者ID:bala1074,项目名称:angular-security-course,代码行数:28,代码来源:server.ts

示例2: commandLineArgs

import {OntoUmlModel} from "./src/OntoUml";
import OntoUmlToOntoObjectModelMapper from "./src/OntoUmlToOntoObjectModelMapper";
import CSharpMapper from "./src/Output/CSharp/CSharpMapper";
import CSharpModelRenderer from "./src/Output/CSharp/CSharpModelRenderer";
import JsonMapper from "./src/Output/Json/JsonMapper";
import JsonRenderer from "./src/Output/Json/JsonRenderer";
import {IOptions, IFrontEnd, ILanguageMapper, ILanguageRenderer} from "./src/Interfaces";
import {OntoObjectModel} from "./src/OntoObjectModel";
import TypeMappingHelper from "./src/TypeMappingHelper";

var cli = commandLineArgs([
    { name: "help", alias: "h", type: Boolean, description: "Displays this help message and quits." },
    { name: "verbose", alias: "v", type: Boolean, description: "Displays additional output." },
    { name: "input", alias: "i", defaultOption: true, type: String, description: "The input file to process." },
    { name: "inputForm", alias: "I", type: String, description: "The input form code. Valid values:\n\"refontouml\":\t RefOntoUml from OLED.\n\"onto-object-model\":\t JSON of the OntoObjectModel.\n Defaults to \"refontouml\"." },
    { name: "output", alias: "o", type: String, description: "The output directory or file (if singleFile flag is set)." },
    { name: "outputForm", alias: "O", type: String, description: "The output form code. Valid values:\n\"csharp-model\":\t model classes with semantic checks in C#\nConfig options:\n-c namespace=<namespaceName> name of the namespace to use\n\n\"onto-object-model\":\t JSON of the OntoObjectModel\n\n Defaults to \"csharp-model\"." },
    { name: "singleFile", alias: "s", type: Boolean, description: "If set, all the generated code will be placed in a single file." },
    { name: "typeMapping", alias: "t", type: String, description: "Path to file containing primitive type mapping definitions." },
    { name: "config", alias: "c", type: String, multiple: true, description: "Additional configuration options in the form <name>=<value>." }
]);
var usageData = {
    title: "OntoUML code generator",
    description: "Generates source code from OntoUML models.",
    footer: "Project home: [underline]{https://github.com/CCMi-FIT/ontouml-code-generator}"
};

function processConfigOptions(rawOptions: IOptions & { config: string[] }): IOptions {
    let result: IOptions = _.cloneDeep(_.omit(rawOptions, "config") as IOptions);
    result.configuration = {};
    _.forEach(rawOptions.config, (pair: string) => {
开发者ID:CCMi-FIT,项目名称:ontouml-code-generator,代码行数:31,代码来源:app.ts

示例3: commandLineArgs

	constructor() {
		this.commandLineParser = commandLineArgs([
			{ name: 'verbose', alias: "v", type: Boolean },
			{ name: 'master', alias: "m", type: String },
			{ name: 'section', alias: "s", type: String }
		]);
	}
开发者ID:duffman,项目名称:packman,代码行数:7,代码来源:commandline.processor.ts

示例4: parseOptions

// Parse the options in argv and split them into global options and renderer options,
// according to each option definition's `renderer` field.  If `partial` is false this
// will throw if it encounters an unknown option.
function parseOptions(definitions: OptionDefinition[], argv: string[], partial: boolean): Partial<CLIOptions> {
    let opts: { [key: string]: any };
    try {
        opts = commandLineArgs(definitions, { argv, partial });
    } catch (e) {
        assert(!partial, "Partial option parsing should not have failed");
        return messageError("DriverCLIOptionParsingFailed", { message: e.message });
    }

    const options: { rendererOptions: RendererOptions; [key: string]: any } = { rendererOptions: {} };
    for (const o of definitions) {
        if (!hasOwnProperty(opts, o.name)) continue;
        const v = opts[o.name] as string;
        if (o.renderer !== undefined) options.rendererOptions[o.name] = v;
        else {
            const k = _.lowerFirst(
                o.name
                    .split("-")
                    .map(_.upperFirst)
                    .join("")
            );
            options[k] = v;
        }
    }
    return options;
}
开发者ID:nrkn,项目名称:quicktype,代码行数:29,代码来源:index.ts

示例5: require

import 'babel-polyfill';
import {createConversation, ALL_CONVERSATIONS}  from './conversations';
import * as Sequelize from 'sequelize';
import {defineModels} from './models';
import {Reminder} from './conversations/reminder';
const commandlineArgs = require('command-line-args');

const parser = commandlineArgs([
  {name: 'force', alias: 'F', type: Boolean,
    description: '強制的にDBスキーマを再作成するか'},
  {name: 'token', alias: 't', type: String, required: true,
    description: 'SlackのAPIトークン'},
  {name: 'reminder-channel', alias: 'c', type: String,
    description: 'リマインダを送信するチャネルの名称'},
  {name: 'help', alias: 'h', type: Boolean,
    description: 'ヘルプを表示する'},
  {name: 'database-url', alias: 'd', type: String, required: true,
    description: 'データベースのURL(例: mysql://user:pass@localhost:3306/hx)'},
]);

const options = parser.parse(process.argv);
// console.log(options);
if (options.help) {
  console.log(parser.getUsage());
  process.exit(0);
}
const token = options.token;
if (!token) {
  console.log('トークンが指定されていません' + parser.getUsage());
  process.exit(1);
}
开发者ID:hxjp,项目名称:simekiri-bot,代码行数:31,代码来源:bot.ts


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