nushell / nushell/nushell

Custom completions should support subcommands after flags

Open
#6,972 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A:completions A:external-commands category:enhancement
Dominant language
Rust
Stars
40.5k
Forks
2.3k
Avg merge
1d 19h
Merged PRs (30d)
85

Description

Related problem

I would like to be able to represent subcommands after flags when working with custom completions:
Often the top level command will have flags that it's necessary to put before the subcommand.

$ cmd --flag subcmd --subflag foo

My naive way of representing this command would be:

export extern cmd [
  --flag
  ...args
]

export extern "cmd subcmd" [
  --subflag
  bar: string
]

But then the completions bottom out after cmd --flag, and I don't get the completions for subcmd

Describe the solution you'd like

It would be great if cmd <options> subcmd just worked, so that after the flags, it "passes through" to the extern "cmd subcmd" definition and uses those completions.

Describe alternatives you've considered

No response

Additional context and details

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the custom completion definitions shown in the issue, especially how extern cmd and extern "cmd subcmd" are selected after flags. Reproduce cmd --flag subcmd --subflag foo and trace completion handling for ...args; done means subcommand completions remain available after top-level flags and the existing extern "cmd subcmd" definition supplies them.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.