MCPcopy Index your code
hub / github.com/toddbluhm/env-cmd / parseArgsUsingCommander

Function parseArgsUsingCommander

src/parse-args.ts:95–117  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

93}
94
95export function parseArgsUsingCommander(args: string[]): CommanderOptions {
96
97 return new Command('env-cmd')
98 .description('CLI for executing commands using an environment from an env file.')
99 .version(packageJson.version, '-v, --version')
100 .usage('[options] -- <command> [...args]')
101 .option('-e, --environments [envs...]', 'The rc file environment(s) to use', parseArgList)
102 .option('-f, --file [path]', 'Custom env file path or .rc file path if \'-e\' used (default path: ./.env or ./.env-cmdrc.(js|cjs|mjs|json))')
103 .option('-x, --expand-envs', 'Replace $var and ${var} in args and command with environment variables')
104 .option('--recursive', 'Replace $var and ${var} in env file with the referenced environment variable')
105 .option('--fallback', 'Fallback to default env file path, if custom env file path not found')
106 .option('--no-override', 'Do not override existing environment variables')
107 .option('--silent', 'Ignore any env-cmd errors and only fail on executed program failure.')
108 .option('--use-shell', 'Execute the command in a new shell with the given environment')
109 .option('--verbose', 'Print helpful debugging information')
110 // TODO: Remove -r deprecation error on version >= v12
111 .addOption(new Option('-r, --rc-file [path]', 'Deprecated Option')
112 .hideHelp()
113 .argParser(() => { throw new CommanderError(1, 'deprecated-option', 'The -r flag has been deprecated, use the -f flag instead.') }))
114 .allowUnknownOption(true)
115 .allowExcessArguments(true)
116 .parse(['_', '_', ...args], { from: 'node' })
117}

Callers 1

parseArgsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected