Some form of flag inheritance for `def` and `extern`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 40.5k
- Forks
- 2.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 85
Description
Related problem
A common pattern in CLI utilities with subcommands is a set of flags, which are shared between all commands (--verbose, --force, and so on).
In Nushell, currently, subcommands are independent of their parent commands. This makes implementing nested commands and extern completions for tools like git or apk tricky, because the global options have to be repeated several times.
Describe the solution you'd like
My idea is to add some kind of inheritance, so that a custom function or an extern can inherit some other command's flags. This allows to enable completely separate subcommands (so, aa x and aa y will, by default, be unrelated), but still provide the option to share flags as an opt-in.
Describe alternatives you've considered
-
Flags as data. For example, flags could be written down as a
long,short,doc,type,default,completertable and be added to a command:const flags = [ { long: "verbose", short: "v", doc: "Print debug information", }, { long: "format", doc: "The format for the dates", type: string, completer: {|| format_func} }, ... ] def command [ ...flags ] { # stuff } -
Automatically inheriting flags for subcommands. So
def aa x ...would inherit the flags ofdef aa, with an opt-out flag indef. Not very elegant, and doesn't work when the root command is calledmain.
Additional context and details
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files, tests, or implementation entry points. It proposes opt-in flag inheritance for def and extern, with shared flags available to nested commands; a concrete design and acceptance criteria are still needed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100