本文整理汇总了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);
示例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) => {
示例3: commandLineArgs
constructor() {
this.commandLineParser = commandLineArgs([
{ name: 'verbose', alias: "v", type: Boolean },
{ name: 'master', alias: "m", type: String },
{ name: 'section', alias: "s", type: String }
]);
}
示例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;
}
示例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);
}