nushell: Some commands that require a subcommand (like `config`) output their `help` when run as-is, but others (like `from`) don't

Describe the bug

See title.

The problematic commands that don’t are from, to and query. query doesn’t even seem to exist without its subcommand.

How to reproduce

〉config
Usage:
  > config

Subcommands:
  config env - Edit nu environment configurations
  config nu - Edit nu configurations
  config reset - Reset nushell environment configurations to default, and saves old config files in the config location as oldconfig.nu and oldenv.nu

Flags:
  -h, --help - Display this help message


〉from
〉to
〉query
Invalid parameter(s)
QUERY { PROCESS | SESSION | TERMSERVER | USER }
〉which query
╭───┬───────┬───────────────────────────────┬──────────╮
│ # │  arg  │             path              │ built-in │
├───┼───────┼───────────────────────────────┼──────────┤
│ 0 │ query │ C:\Windows\system32\query.exe │ false    │
╰───┴───────┴───────────────────────────────┴──────────╯

Expected behavior

I expect all commands that require subcommands to output their help when run without a subcommand.

Screenshots

No response

Configuration

key value
version 0.70.0
branch
commit_hash 9ef65dcd692b502d7476b1787247fae8638c2f0c
build_os windows-x86_64
build_target x86_64-pc-windows-msvc
rust_version rustc 1.64.0 (a55dd71d5 2022-09-19)
rust_channel stable-x86_64-pc-windows-msvc
cargo_version cargo 1.64.0 (387270bc7 2022-09-16)
pkg_version 0.70.0
build_time 2022-10-18 18:55:02 +00:00
build_rust_channel release
features database, dataframe, default, trash, which, zip
installed_plugins

Additional context

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 15 (9 by maintainers)

Commits related to this issue

Most upvoted comments

what file handles the registering of sub commands?

not sure, there is default_context.rs in nu-command to add new commands but, otherwise, subcommands are detected automatically, e.g. if you define a subcommand for ls

def "ls foo" [] {}

running help ls will show the foo subcommand directly without any extra step 😉

Also, is this good to make a pr or should i add to it?

i think it’s fine to add query in a PR 👍

im having a lot of issues squashing commits. im very sorry. im just going to take a break

what file handles the registering of sub commands?

not sure, there is default_context.rs in nu-command to add new commands but, otherwise, subcommands are detected automatically, e.g. if you define a subcommand for ls

def "ls foo" [] {}

running help ls will show the foo subcommand directly without any extra step 😉

Also, is this good to make a pr or should i add to it?

i think it’s fine to add query in a PR 👍

@sigh-gone yeah, i think that’s normal 👌 query db is there by default, the others should appear once they are registered

So quick question, do you want me to change this from the Plugin trait to the Command trait? Both the Plugin trait and the Command trait have signature methods. I apologize if this is obvious, im still trying to figure out what all this does.

let’s try to just add a new command without changing traits 😉

Also, should query.rs be moved from the nu_plugin_query directory if i need to implement command on it?

nu_plugin_query already has a query.rs and ships a query command when registered. so you could try to add a query.rs next to query_db.rs to nu-command and see if it does not conflict with the nu_plugin_query plugin once registered

@sigh-gone i meant that, afaik, there is no implementation of the Command trait for the Query struct in query.rs, which is why it’s not a Nushell command even though query db is one!

if you look at any other Nushell command, e.g. from and to to stay in the topic here, you’ll see implementations of the Command trait https://github.com/nushell/nushell/blob/cd0a52cf00a508476574d94f66b0841387df1631/crates/nu-command/src/formats/from/command.rs#L9 https://github.com/nushell/nushell/blob/cd0a52cf00a508476574d94f66b0841387df1631/crates/nu-command/src/formats/to/command.rs#L9

but also things like ls https://github.com/nushell/nushell/blob/cd0a52cf00a508476574d94f66b0841387df1631/crates/nu-command/src/filesystem/ls.rs#L25