Skip to content

Shell completion follow-on: complete per-verb argument values #2097

Description

@johnkerl

Follow-up from the shell-completion work (#2096): complete the argument values of verb flags. Today verb-flag values fall back to filename completion. The completion engine already records (verb, flag) at a value position, so this is "fill in a provider," not new architecture. Three sub-problems with different cost/value:

1. Enumerated keyword values (easy, high value, no I/O)

Flags whose argument is a closed set defined in Miller's code:

  • stats1 -a, merge-fields -a → accumulator names (sum mean count median p50 stddev …), from stats1AccumulatorInfos in pkg/transformers/utils/stats1_accumulators.go
  • stats2 -alinreg-ols r2 cov corr …
  • step -a → stepper names (delta shift shift_lag rsum ewma …)
  • a few smaller fixed sets (case, format-values, …)

Mirrors the existing main-flag enum completion (-i/--ifs); needs a small (verb, flag) → values table plus getters so the lists don't drift. Low risk.

2. Field names (high value, architecturally thorny)

cut -f <TAB>, sort -nf <TAB>, stats1 -g <TAB> → the data's column names. Requires reading the input header, which runs into:

  • The input file is often not on the command line yet (typed after the verb, or piped on stdin) → nothing to read.
  • When present, the filename can be before (--from) or after the verb → must scan the whole line.
  • Must honor format flags (--icsv/--itsv/--ijson, custom separators, implicit header) → partially invoke the reader factory; adds I/O + latency.
  • Comma-separated lists (cut -f a,b,<TAB>) are one shell word → parse past the last comma and suppress already-chosen fields.

Should be gated so it never errors/slows a TAB when no readable file is discoverable. Medium-large; deserves its own design.

3. Plain strings / filenames (nothing to do)

head -n, sample -k → arbitrary; put -f, tee, join -f → filenames (already handled by the file fallback).

Suggested order

Ship #1 first (cheap, safe). Treat #2 as a separate effort. #3 needs nothing.

Lower priority.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions