Thanks to visit codestin.com
Credit goes to gro.fuz.dev

args.ts

view source

Declarations
#

6 declarations

print_command_args
#

to_forwarded_args
#

args.ts view source

(command: string, raw_rest_args?: string[] | undefined, cache?: Record<string, Args | undefined>): Args import {to_forwarded_args} from '@fuzdev/gro/args.js';

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> import {to_forwarded_args_by_command} from '@fuzdev/gro/args.js';

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 import {to_implicit_forwarded_args} from '@fuzdev/gro/args.js';

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[] import {to_raw_rest_args} from '@fuzdev/gro/args.js';

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; } import {to_task_args} from '@fuzdev/gro/args.js';

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
#