當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。