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


TypeScript argv.option函數代碼示例

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


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

示例1: constructor

 constructor() {
     const args = argv
         .option({ name: "androidId", short: "a", type: "string" })
         .option({ name: "token", short: "t", type: "string" })
         .option({ name: "input", short: "i", type: "list,string" })
         .option({ name: "output", short: "o", type: "list,string" })
         .option({ name: "overwrite", type: "boolean" })
         .option({ name: "maxTracksPerPlaylist", short: "m", type: "number" })
         .option({ name: "singlePlaylist", type: "boolean" })
         .run();
     this.androidId = args.options["androidId"];
     this.token = args.options["token"];
     this.input = args.options["input"];
     this.output = args.options["output"];
     this.overwrite = args.options["overwrite"] === true;
     this.maxTracksPerPlaylist = parseInt(args.options["maxTracksPerPlaylist"]) || 0;
     this.singlePlaylist = args.options["singlePlaylist"] === true;
     this.validate();
 }
開發者ID:nickp10,項目名稱:shuffler,代碼行數:19,代碼來源:args.ts

示例2:

//////////////////////////////////////////////////

import * as argv from 'argv';

argv.option([{
	name: 'version',
	short: 'v',
	type: 'boolean',
	description: 'Display version',
	example: "misskey-web-logger -v"
}, {
	name: 'web',
	short: 'w',
	type: 'boolean',
	description: 'Serve Web',
	example: "misskey-web-logger -w"
}, {
	name: 'port',
	short: 'p',
	type: 'int',
	description: 'Web port',
	example: "misskey-web-logger -w -p 907"
}, {
	name: 'debug',
	type: 'boolean',
	description: 'Enable debug mode',
	example: "misskey-web-logger --debug"
}]);

export default argv.run();
開發者ID:syuilo,項目名稱:misskey-web-logger,代碼行數:30,代碼來源:argv.ts

示例3: start

	async start() {

		const log = (...params: any[]) => {
			console.log('[ComponentEngine]', ...params);
		};

		log('database: connecting ...');
		const db = await MongoProvider.connect(this.mongoInfo.url, this.mongoInfo.dbName);

		log('components: initializing ...');
		const initializedData: { component: IComponent, setupMenu?: ConsoleMenu }[] = [];
		for (const component of this.components) {
			if (component.init) {
				initializedData.push({
					component: component,
					setupMenu: (await component.init({ db })).setupMenu
				});
			}
		}

		// options

		argv.option({
			name: 'setup',
			short: 's',
			type: 'boolean',
			description: 'Display setup mode'
		});

		const { options } = argv.run();

		// (mode) setup

		if (options.setup) {

			log('setup mode');

			const setupMenus = initializedData
				.map(c => { return { setupMenu: c.setupMenu, component: c.component }; })
				.filter((c): c is { setupMenu: ConsoleMenu, component: IComponent } => c.setupMenu != null);

			await setupComponentMenu(setupMenus);

			log('database: disconnecting ...');
			await db.disconnect();

			return;
		}

		// (mode) server

		log('server mode');

		const apiInternal = new ComponentApiInternal(this, db);

		log('components: starting ...');

		try {
			for (const component of this.components) {
				await component.handler(new ComponentApi(apiInternal, component));
			}
		}
		catch (err) {
			log('component error:');
			console.error(err);

			log('database: disconnecting ...');
			await db.disconnect();

			return;
		}

		// http

		log('http: initialize ...');

		const app = Express();
		app.set('views', apiInternal.http.viewPathes);
		app.set('view engine', 'pug');

		app.use(passport.initialize());

		log('http: registering init handlers ...');

		for (const initHandler of apiInternal.http.initHandlers) {
			await initHandler(app);
		}

		log('http: registering route handlers ...');

		for (const routeHandler of apiInternal.http.routeHandlers) {
			await routeHandler(app);
		}

		app.listen(this.httpPort, () => {
			log('http: started server.');
		});

		log('ready.');
	}
開發者ID:Frost-Dev,項目名稱:Frost,代碼行數:100,代碼來源:ComponentEngine.ts

示例4:

//////////////////////////////////////////////////
// ARGV MANAGER
//////////////////////////////////////////////////

import * as argv from 'argv';

argv.option({
	name: 'skip-check-dependencies',
	type : 'string',
	description: '依存関係のチェックをスキップします',
	example: "npm start --skip-check-dependencies"
});

export default argv.run();
開發者ID:syuilo,項目名稱:misskey-file,代碼行數:14,代碼來源:argv.ts


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