mirror of
https://github.com/toddbluhm/env-cmd.git
synced 2025-12-08 18:23:33 +00:00
fix(parse-args): add helpful -r flag deprecation error message
This commit is contained in:
parent
592ad064fb
commit
e2db12b878
6
dist/parse-args.js
vendored
6
dist/parse-args.js
vendored
@ -1,4 +1,4 @@
|
||||
import { Command } from '@commander-js/extra-typings';
|
||||
import { Command, Option, CommanderError } from '@commander-js/extra-typings';
|
||||
import { parseArgList } from './utils.js';
|
||||
import packageJson from '../package.json' with { type: 'json' };
|
||||
/**
|
||||
@ -89,6 +89,10 @@ export function parseArgsUsingCommander(args) {
|
||||
.option('--silent', 'Ignore any env-cmd errors and only fail on executed program failure.')
|
||||
.option('--use-shell', 'Execute the command in a new shell with the given environment')
|
||||
.option('--verbose', 'Print helpful debugging information')
|
||||
// TODO: Remove -r deprecation error on version >= v12
|
||||
.addOption(new Option('-r, --rc-file [path]', 'Deprecated Option')
|
||||
.hideHelp()
|
||||
.argParser(() => { throw new CommanderError(1, 'deprecated-option', 'The -r flag has been deprecated, use the -f flag instead.'); }))
|
||||
.allowUnknownOption(true)
|
||||
.allowExcessArguments(true)
|
||||
.parse(['_', '_', ...args], { from: 'node' });
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Command } from '@commander-js/extra-typings'
|
||||
import { Command, Option, CommanderError } from '@commander-js/extra-typings'
|
||||
import type { EnvCmdOptions, CommanderOptions, EnvFileOptions, RCFileOptions } from './types.ts'
|
||||
import { parseArgList } from './utils.js'
|
||||
import packageJson from '../package.json' with { type: 'json' }
|
||||
@ -88,6 +88,7 @@ export function parseArgs(args: string[]): EnvCmdOptions {
|
||||
}
|
||||
|
||||
export function parseArgsUsingCommander(args: string[]): CommanderOptions {
|
||||
|
||||
return new Command('env-cmd')
|
||||
.description('CLI for executing commands using an environment from an env file.')
|
||||
.version(packageJson.version, '-v, --version')
|
||||
@ -100,6 +101,10 @@ export function parseArgsUsingCommander(args: string[]): CommanderOptions {
|
||||
.option('--silent', 'Ignore any env-cmd errors and only fail on executed program failure.')
|
||||
.option('--use-shell', 'Execute the command in a new shell with the given environment')
|
||||
.option('--verbose', 'Print helpful debugging information')
|
||||
// TODO: Remove -r deprecation error on version >= v12
|
||||
.addOption(new Option('-r, --rc-file [path]', 'Deprecated Option')
|
||||
.hideHelp()
|
||||
.argParser(() => { throw new CommanderError(1, 'deprecated-option', 'The -r flag has been deprecated, use the -f flag instead.') }))
|
||||
.allowUnknownOption(true)
|
||||
.allowExcessArguments(true)
|
||||
.parse(['_', '_', ...args], { from: 'node' })
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user