/** * @file Positional-argument extraction that survives value-taking flags. * Pairs with `shell/parse`, which tokenizes a shell string into an `argv` * array — this operates on that resulting array, downstream of * tokenization. * The naive form — `args.filter(a => !a.startsWith('-'))` — is wrong for * every CLI that has a flag consuming the next token: `gh --repo o/r pr * create` yields `['o/r', 'pr', 'create']`, so a caller checking * `words[0] === 'pr'` silently stops matching. Code is law: the correct * parse lives here once, with the value-flag tables, instead of being * re-derived (and re-broken) per caller. */ /** * `gh` flags whose NEXT token is a value. Only the ones a caller is * plausibly parsing around need listing — an unlisted value flag degrades to * the naive behavior, which is what a hand-rolled positional scan already had. */ export declare const GH_VALUE_FLAGS: ReadonlySet; /** * `npm` (and `pnpm`/`yarn`) flags whose NEXT token is a value. */ export declare const NPM_VALUE_FLAGS: ReadonlySet; /** * `git` flags whose NEXT token is a value. */ export declare const GIT_VALUE_FLAGS: ReadonlySet; /** * Positional (non-flag) words from `argv`, skipping value-taking flags AND * the token each consumes. * * `limit` stops the scan early: a caller usually needs only the first one or * two words, and stopping keeps a later free-text value (a `--body` that * happens to read `pr create`) from being mistaken for a subcommand. * `--flag=value` needs no special case — it never consumes a next token. * * @example * positionalArgs(['--repo', 'o/r', 'pr', 'create'], GH_VALUE_FLAGS) * // → ['pr', 'create'] * * positionalArgs(['--title=x', 'pr', 'create'], GH_VALUE_FLAGS, 1) * // → ['pr'] * * positionalArgs(['commit', '--', '-m'], GIT_VALUE_FLAGS) * // → ['commit', '-m'] */ export declare function positionalArgs(argv: readonly string[], valueFlags: ReadonlySet, limit?: number): string[];