function tokenize
tokenize(args: readonly string[]): ArgToken[]

Classifies argv into query / flag / input tokens.

A bare query flag (-t, no =) is greedy: it swallows every following entry up to — but not including — the next --prefixed entry (or end of argv), joined with spaces. That is what lets -t Some Module loading tests --junit read as filter "Some Module loading tests" without quotes. The = form (--filter=x) stays a single token, so a value that legitimately starts with - is still reachable that way.

A -- entry is the POSIX end-of-options marker: everything after it is a positional input, so -t a b -- test/foo scopes the run to test/foo while keeping "a b" as the filter.

import * as Args from './index.ts';

Args.tokenize(['-t', 'Cart', 'checkout', '--watch']);
// [{ kind: 'query', action: 'run', value: 'Cart checkout', greedy: true },
//  { kind: 'flag', raw: '--watch' }]
Args.tokenize(['-t', 'a b', '--', 'test/cart-test.ts']).at(-1); // { kind: 'input', raw: 'test/cart-test.ts' }

Parameters

args: readonly string[]

Return Type

Usage

import { tokenize } from "lib/args/tokenize.ts";