Skip to content

Added help externs command#8403

Merged
sholderbach merged 5 commits intonushell:mainfrom
klementievdmitry:main
Mar 15, 2023
Merged

Added help externs command#8403
sholderbach merged 5 commits intonushell:mainfrom
klementievdmitry:main

Conversation

@klementievdmitry
Copy link
Copy Markdown
Contributor

@klementievdmitry klementievdmitry commented Mar 11, 2023

Description

help externs - command, which list external commands

Closes #8301

User-Facing Changes

$ help externs
╭───┬──────────────┬─────────────┬───────────────────────────────────────────────────╮
│ # │     name     │ module_name │                       usage                       │
├───┼──────────────┼─────────────┼───────────────────────────────────────────────────┤
│ 0 │ git push     │ completions │ Push changes                                      │
│   │              │             │                                                   │
│ 1 │ git fetch    │ completions │ Download objects and refs from another repository │
│   │              │             │                                                   │
│ 2 │ git checkout │ completions │ Check out git branches and files                  │
│   │              │             │                                                   │
╰───┴──────────────┴─────────────┴───────────────────────────────────────────────────╯

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.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 11, 2023

Codecov Report

Merging #8403 (0ec069e) into main (e435196) will decrease coverage by 0.07%.
The diff coverage is 31.44%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8403      +/-   ##
==========================================
- Coverage   68.25%   68.18%   -0.07%     
==========================================
  Files         620      621       +1     
  Lines       99355    99514     +159     
==========================================
+ Hits        67813    67857      +44     
- Misses      31542    31657     +115     
Impacted Files Coverage Δ
crates/nu-engine/src/scope.rs 81.36% <0.00%> (-5.96%) ⬇️
...ates/nu-cmd-lang/src/core_commands/help_externs.rs 41.88% <41.88%> (ø)
crates/nu-cmd-lang/src/default_context.rs 98.52% <100.00%> (+0.02%) ⬆️

... and 2 files with indirect coverage changes

@amtoine
Copy link
Copy Markdown
Member

amtoine commented Mar 11, 2023

This should close #8301 👌

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Mar 11, 2023

If we're going to have this command, I'd rather call it help extern since it shows up here $nu.scope.commands | where is_extern == true as is_extern.

I also think that it would be good to have the module_name column.

The category, signatures, and search_terms don't seem particularly useful.

Just my two cents.

@klementievdmitry klementievdmitry changed the title Added help external command Added help extern command Mar 11, 2023
@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Mar 11, 2023

@klementievdmitry oops, I made a mistake. Sorry, but we can't use help extern because we already have an extern command and help extern shows that help. Maybe making it plural is ok like help externs, unless you have a better suggestion.

@klementievdmitry
Copy link
Copy Markdown
Contributor Author

Well, I didn't even think about it, I just did 😄, and I have no other ideas.

@klementievdmitry klementievdmitry changed the title Added help extern command Added help externs command Mar 12, 2023
@kubouch
Copy link
Copy Markdown
Contributor

kubouch commented Mar 12, 2023

I'm thinking help externals is clearer and even more distinct. Otherwise, I'm ok with this PR.

@kubouch
Copy link
Copy Markdown
Contributor

kubouch commented Mar 12, 2023

One thing we might do is to remove aliases and externals from help commands, and make better customized individual help messages for them. The externals discovery should also be added here

} else {
let result = help_aliases(engine_state, stack, call);
let result = if let Err(ShellError::AliasNotFound(_)) = result {
help_commands(engine_state, stack, call)
} else {
result
};
let result = if let Err(ShellError::CommandNotFound(_)) = result {
help_modules(engine_state, stack, call)
} else {
result
};
if let Err(ShellError::ModuleNotFoundAtRuntime {
mod_name: _,
span: _,
}) = result
{
let rest_spans: Vec<Span> = rest.iter().map(|arg| arg.span).collect();
Err(ShellError::NotFound {
span: span(&rest_spans),
})
} else {
result
}
}
. help name should be different based on whether name is a command, alias or known external. I think known externals might have one already, not sure, but the aliases should show a more customized message in addition to showing the wrapped command's help message. But these changes can be done in a future PR.

Ultimately, the help commands could be re-implemented in Nu code as a part of the standard library so that's also something to consider in the future.

@amtoine
Copy link
Copy Markdown
Member

amtoine commented Mar 12, 2023

(@kubouch added to the task list in #8311 😉)

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Mar 12, 2023

I'm thinking help externals is clearer and even more distinct. Otherwise, I'm ok with this PR.

I think help externals is confusing because your file system is filled with externals that are not nushell built-ins. Is help externals supposed to list everything on your file system that isn't a built-in? Also, if we're going to be consistent, then it should match is_extern but we can't have help extern because extern is a built-in. Which is why it's plural now. So, I'm voting against help externals since it's so confusing.

@kubouch
Copy link
Copy Markdown
Contributor

kubouch commented Mar 12, 2023

OK, let's keep it help externs then. Alternative is help known-externals but that seems too verbose...

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Mar 12, 2023

I agree that help known-externals is too verbose but it is descriptive. I'm up for something else too, as long as it's less confusing. overloaded terms like extern are confusing. maybe the nushell code should call them something else too.

@sholderbach
Copy link
Copy Markdown
Member

I would like to move ahead with this even though I can understand the arguments for and against certain naming decisions.

@sholderbach sholderbach merged commit 4de0347 into nushell:main Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aliases should be listed in help alias or $nu.scope.aliases and externals in help externals

5 participants