Skip to content

let UnknownFlag error list out available flags - #7443

Merged
fdncred merged 4 commits into
nushell:mainfrom
merelymyself:module_constant
Dec 13, 2022
Merged

fdncred merged 4 commits into
nushell:mainfrom
merelymyself:module_constant

Conversation

@merelymyself

Copy link
Copy Markdown
Contributor

Description

Fixes #6773.

/home/gabriel/CodingProjects/nushell〉ls -r                                                                                                                             12/12/2022 02:57:35 PM
Error: nu::parser::unknown_flag (link)

  × The `ls` command doesn't have flag `-r`.
   ╭─[entry #1:1:1]
 1 │ ls -r
   ·     ┬
   ·     ╰── unknown flag
   ╰────
  help: Available flags: --help(-h), --all(-a), --long(-l), --short-names(-s), --full-paths(-f), --du(-d), --directory(-D). Use `--help` for more information.

User-Facing Changes

Different error for unknown flag.

Tests + Formatting

Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

  • cargo fmt --all -- --check to check standard code formatting (cargo fmt --all applies these changes)
  • cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

@sholderbach sholderbach left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love those helpful errors!

Wondering if we should limit the max available suggestions or fuzzy match.
Also slight comment about the string building.

Comment thread crates/nu-protocol/src/signature.rs Resolved
Comment thread crates/nu-protocol/src/signature.rs Resolved
@fdncred

fdncred commented Dec 12, 2022

Copy link
Copy Markdown
Contributor

nice, that seems helpful. I kind of wonder if a sprawling line of commands would be better displayed wrapped at a particular column? But I'm up landing and trying out for a while to see if it needs tweaking.

@sholderbach sholderbach left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! That's nice especially with the added hint to use --help!

@fdncred
fdncred merged commit 0c4d463 into nushell:main Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nu::parser::unknown_flag errors could just list the flags instead of saying "use <command> --help for a list of flags"

3 participants