/** * Parses the command-line arguments, extracting the tsickle settings and * the arguments to pass on to tsc. */ function loadSettingsFromArgs(args: string[]): {settings: Settings, tscArgs: string[]} { const settings: Settings = {}; const parsedArgs = minimist(args); for (const flag of Object.keys(parsedArgs)) { switch (flag) { case 'h': case 'help': usage(); process.exit(0); break; case 'externs': settings.externsPath = parsedArgs[flag]; break; case 'typed': settings.isTyped = true; break; case 'verbose': settings.verbose = true; break; case '_': // This is part of the minimist API, and holds args after the '--'. break; default: console.error(`unknown flag '--${flag}'`); usage(); process.exit(1); } } // Arguments after the '--' arg are arguments to tsc. const tscArgs = parsedArgs['_']; return {settings, tscArgs}; }
export default function cmd(args) { let argv = minimist(args); startServer({ directory: argv['dir'] || config.directory, port: argv['port'] || config.port }); }
getArgumentsObject(args: string[]): Arguments{ let obj : any = minimist(this.removeNodeAndFilename(args)); let sortBy = "main.temp"; if('sortBy' in obj){ sortBy = obj.sortBy } return new Arguments(obj._, sortBy) }
export function loadArgs(args: string[], defaults = DEFAULTS) { let config = R.clone(defaults); let argv = minimist(args, OPTIONS); if (argv['config']) { let file = argv['config']; if (typeof file === 'string') config = loadFile(file, config); } let object: any = {}; object.client = {}; if (argv['client']) object.client.name = argv['client']; if (argv['client-config']) { let clientConfig = argv['client-config']; if (typeof clientConfig === 'string') { object.client.config = JSON.parse(clientConfig); } } if (argv['journal-table']) object.client.journalTable = argv['journal-table']; if (argv['directory']) object.files = {directory: argv['directory']}; if (argv['status']) object.command = 'status'; if (argv['migrations']) object.command = 'migrations'; if (argv['journal']) object.command = 'journal'; if (argv['create']) object.command = 'create'; if (argv['apply']) object.command = 'apply'; if (argv['revert']) object.command = 'revert'; if (argv['help']) object.command = 'help'; if (argv['version']) object.command = 'version'; let command: any = {}; object.commands = {[object.command]: command}; if (argv['id']) command.id = argv['id']; if (argv['long']) command.long = true; if (argv['combined']) command.split = false; if (argv['split']) command.split = true; command.templatePaths = {}; if (argv['template']) command.templatePaths.combined = argv['template']; if (argv['up-template']) command.templatePaths.up = argv['up-template']; if (argv['down-template']) command.templatePaths.down = argv['down-template']; if (argv['all']) command.method = 'all'; if (argv['each']) command.method = 'each'; if (argv['dry']) command.method = 'dry'; if (argv['pending']) command.pending = true; if (argv['to']) command.to = argv['to']; if (argv['number']) command.number = argv['number']; if (argv['_'].length) command.name = argv['_'].join('-'); return loadObject(object, config); }
return Promise.resolve().then(() => { let args = minimist(environment.args); let RegisteredCommand = findCommand(environment.commands, args._[0]); let command = new RegisteredCommand({ ui: this.ui, project: this.project }); return command.validateAndRun(environment.args); }).catch(this.error.bind(this));
function main(): void { const opts = minimist<PublishOptions>(process.argv.slice(2), { boolean: ['upload-only'] }); const [quality, platform, type, name, version, _isUpdate, file] = opts._; const commit = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim(); publish(commit, quality, platform, type, name, version, _isUpdate, file, opts).catch(err => { console.error(err); process.exit(1); }); }
async function main() { // Parse the command-line options. let args = minimist(process.argv.slice(2), { boolean: ['v', 'c', 'x', 'w', 't', 'g', 'P'], }); // The flags: -v, -c, and -x. let verbose: boolean = args['v']; let compile: boolean = args['c']; let execute: boolean = args['x']; let webgl: boolean = args['w']; let test: boolean = args['t']; let generate: boolean = args['g']; let no_presplice: boolean = args['P']; let module: boolean = args['m']; // Help. if (args['h'] || args['help'] || args['?']) { console.error("usage: " + process.argv[1] + " [-vcxwtgP] [PROGRAM...]"); console.error(" -v: verbose mode"); console.error(" -c: compile (as opposed to interpreting)"); console.error(" -x: execute the program (use with -c)"); console.error(" -w: use the WebGL language variant"); console.error(" -t: test mode (check for expected output)"); console.error(" -g: dump generated code"); console.error(" -P: do not use the presplicing optimization"); console.error(" -m: compile an importable ES6 module"); process.exit(1); } // Get the program filenames, or indicate that we'll read code from STDIN. let filenames: string[] = args._; if (!filenames.length) { filenames = [STDIN_FILENAME]; } // Log stuff, if in verbose mode. let log = verbose ? verbose_log : (() => void 0); // Read each source file and run the driver. let success = true; await Promise.all(filenames.map(async fn => { let source = await readText(fn); success = run(fn, source, webgl, compile, execute, test, generate, log, !no_presplice, module) && success; })); if (!success) { process.exit(1); } }
async function main(args: string[]): Promise<number> { /** Parse the command line. */ const argv = minimist(args, { boolean: ['help'] }); /** Create the DevKit Logger used through the CLI. */ const logger = createConsoleLogger(argv['verbose']); // Check the target. const targetStr = argv._[0] || ''; if (!targetStr || argv.help) { // Show architect usage if there's no target. usage(logger); } // Load workspace configuration file. const currentPath = process.cwd(); const configFileNames = [ 'angular.json', '.angular.json', 'workspace.json', '.workspace.json', ]; const configFilePath = findUp(configFileNames, currentPath); if (!configFilePath) { logger.fatal(`Workspace configuration file (${configFileNames.join(', ')}) cannot be found in ` + `'${currentPath}' or in parent directories.`); return 3; } const root = path.dirname(configFilePath); const configContent = readFileSync(configFilePath, 'utf-8'); const workspaceJson = JSON.parse(configContent); const registry = new schema.CoreSchemaRegistry(); registry.addPostTransform(schema.transforms.addUndefinedDefaults); const host = new NodeJsSyncHost(); const workspace = new experimental.workspace.Workspace(normalize(root), host); await workspace.loadWorkspaceFromJson(workspaceJson).toPromise(); // Clear the console. process.stdout.write('\u001Bc'); return await _executeTarget(logger, workspace, root, argv, registry); }
function parseArgs(args: string[] | undefined): minimist.ParsedArgs { return minimist(args, { boolean: booleanArgs, alias: { 'dryRun': 'dry-run', 'listSchematics': 'list-schematics', 'allowPrivate': 'allow-private', }, default: { 'debug': null, 'dry-run': null, }, '--': true, }); }
/** * Reads package prefix and all package names passed as command line arguments. * List of supported arguments: * --prefix - prefix of the package. Also used as prefix in class names, selector prefixes etc. * --auth - replacement for @nebular/auth * --bootstrap - replacement for @nebular/bootstrap * --date-fns - replacement for @nebular/date-fns * --eva-icons - replacement for @nebular/eva-icons * --moment - replacement for @nebular/moment * --theme - replacement for @nebular/theme * --security - replacement for @nebular/security * @param argv command line arguments * @returns ParsedArguments */ function parseArguments(argv: string[]): ParsedArguments { const args = minimist(argv.slice(2)); const prefix = args.prefix; if (!prefix) { throwNoPrefixSpecified(); } const parsedArguments = { prefix }; for (const packageName of NEBULAR_PACKAGES) { parsedArguments[packageName] = args[dasherize(packageName)]; } return parsedArguments; }