args.ts

Declarations
#

6 declarations

view source

print_command_args
#

to_forwarded_args
#

args.ts view source

(command: string, raw_rest_args?: string[] | undefined, cache?: Record<string, Args | undefined>): Args

Parses process.argv for the specified command, so given gro taskname arg1 --arg2 -- eslint eslintarg1 --eslintarg2 -- tsc --tscarg1 --tscarg2 the command 'eslint' returns eslintarg1 --eslintarg2 and 'tsc' returns --tscarg1 and --tscarg2.

command

type string

raw_rest_args?

type string[] | undefined
optional

cache

type Record<string, Args | undefined>
default to_forwarded_args_by_command(raw_rest_args)

returns

Args

to_forwarded_args_by_command
#

args.ts view source

(raw_rest_args?: string[]): Record<string, Args | undefined>

raw_rest_args

type string[]
default to_raw_rest_args()

returns

Record<string, Args | undefined>

to_implicit_forwarded_args
#

args.ts view source

(command_to_strip?: string | undefined, raw_rest_args?: string[]): Args

Gets all args after the first -- without assuming a command name. This is useful for tasks that want to forward args directly to a tool without requiring users to specify the tool name explicitly. Optionally strips a specific command name if present for backward compatibility.

command_to_strip?

type string | undefined
optional

raw_rest_args

type string[]
default to_raw_rest_args()

returns

Args

examples

// `gro test -- --watch` → {watch: true} // `gro test -- foo.test.ts` → {_: ['foo.test.ts']} // `gro test -- vitest --watch` with command_to_strip='vitest' → {watch: true} to_implicit_forwarded_args('vitest')

to_raw_rest_args
#

args.ts view source

(argv?: string[]): string[]

Gets the array of raw string args starting with the first --, if any.

argv

type string[]
default process.argv

returns

string[]

to_task_args
#

args.ts view source

(argv?: string[]): { task_name: string; args: Args; }

Parses task_name and args from process.argv, ignoring anything after any --.

argv

type string[]
default process.argv

returns

{ task_name: string; args: Args; }

Imported by
#