Skip to content

Shell completion descriptions may mislabel input files and output archive #979

Description

@mr-yifeiwang

Version

0.7.1

Description

Shell completions for ouch compress can show misleading completion descriptions.

Current Behavior

When I'm typing ouch compress (a space in the end), the hint shows:

~/Projects/test
> ls
file.txt

~/Projects/test
> ouch compress 
output -- The resulting file. Its extensions can be used to specify the compression formats // completion desc

Then, I continue typing ouch compress file.txt (a space in the end):

~/Projects/test
> ouch compress file.txt
files -- Files to be compressed // completion desc

This is confusing because users expect ouch compress <FILES>... <OUTPUT>, but completion description can make it look as ouch compress <OUTPUT> <FILES>....

Expected Behavior

Completion descriptions should reflect the documented argument order: ouch compress <FILES>... <OUTPUT>. They should not suggest that the output archive comes before the input files.

Likely Cause

CAUTION: The content in this section is suggested by openai/gpt-5.5.

// src/cli/args.rs
Subcommand::Compress {
    /// Files to be compressed
    #[arg(required = true, value_hint = ValueHint::FilePath)]
    files: Vec<PathBuf>,

    /// The resulting file. Its extensions can be used to specify the compression formats
    #[arg(required = true, value_hint = ValueHint::FilePath)]
    output: PathBuf,
}

A variadic positional argument followed by another required positional is parseable once the full command is known, but it is inherently hard for shell completion because the command line is incomplete while completion is being requested.

build.rs appears to only expose this via generated completions:

for shell in Shell::value_variants() {
    generate_to(*shell, cmd, "ouch", out).unwrap();
}

Possible Fixes

CAUTION: The content in this section is suggested by openai/gpt-5.5.

  1. Prefer an explicit output option for future CLI shape, e.g.

    ouch compress file1 file2 --output archive.zip

    This removes the ambiguity for completions.

  2. If preserving the current syntax is required, add custom completion behavior for compress so completions do not present misleading files/output labels.

  3. At minimum, adjust generated/manual completion text to avoid suggesting that output comes before input files.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions