mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 06:30:08 +02:00
split $nu variable into scope commands and simpler $nu (#9487)
# Description This splits off `scope` from `$nu`, creating a set of `scope` commands for the various types of scope you might be interested in. This also simplifies the `$nu` variable a bit. # User-Facing Changes This changes `$nu` to be a bit simpler and introduces a set of `scope` subcommands. # 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 -A clippy::result_large_err` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass - `cargo run -- crates/nu-std/tests/run.nu` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. -->
This commit is contained in:
@ -74,11 +74,11 @@ def get-all-operators [] { return [
|
||||
]}
|
||||
|
||||
def "nu-complete list-aliases" [] {
|
||||
$nu.scope.aliases | select name usage | rename value description
|
||||
scope aliases | select name usage | rename value description
|
||||
}
|
||||
|
||||
def "nu-complete list-modules" [] {
|
||||
$nu.scope.modules | select name usage | rename value description
|
||||
scope modules | select name usage | rename value description
|
||||
}
|
||||
|
||||
def "nu-complete list-operators" [] {
|
||||
@ -91,11 +91,11 @@ def "nu-complete list-operators" [] {
|
||||
}
|
||||
|
||||
def "nu-complete list-commands" [] {
|
||||
$nu.scope.commands | select name usage | rename value description
|
||||
scope commands | select name usage | rename value description
|
||||
}
|
||||
|
||||
def "nu-complete list-externs" [] {
|
||||
$nu.scope.commands | where is_extern | select name usage | rename value description
|
||||
scope commands | where is_extern | select name usage | rename value description
|
||||
}
|
||||
|
||||
def build-help-header [
|
||||
@ -239,7 +239,7 @@ export def modules [
|
||||
...module: string@"nu-complete list-modules" # the name of module to get help on
|
||||
--find (-f): string # string to find in module names
|
||||
] {
|
||||
let modules = $nu.scope.modules
|
||||
let modules = (scope modules)
|
||||
|
||||
if not ($find | is-empty) {
|
||||
$modules | find $find --columns [name usage]
|
||||
@ -345,7 +345,7 @@ export def aliases [
|
||||
...alias: string@"nu-complete list-aliases" # the name of alias to get help on
|
||||
--find (-f): string # string to find in alias names
|
||||
] {
|
||||
let aliases = ($nu.scope.aliases | sort-by name)
|
||||
let aliases = (scope aliases | sort-by name)
|
||||
|
||||
if not ($find | is-empty) {
|
||||
$aliases | find $find --columns [name usage]
|
||||
@ -382,7 +382,7 @@ export def externs [
|
||||
--find (-f): string # string to find in extern names
|
||||
] {
|
||||
let externs = (
|
||||
$nu.scope.commands
|
||||
scope commands
|
||||
| where is_extern
|
||||
| select name module_name usage
|
||||
| sort-by name
|
||||
@ -557,7 +557,7 @@ def build-command-page [command: record] {
|
||||
]
|
||||
} else { [] })
|
||||
|
||||
let subcommands = ($nu.scope.commands | where name =~ $"^($command.name) " | select name usage)
|
||||
let subcommands = (scope commands | where name =~ $"^($command.name) " | select name usage)
|
||||
let subcommands = (if not ($subcommands | is-empty) {[
|
||||
(build-help-header "Subcommands")
|
||||
($subcommands | each {|subcommand |
|
||||
@ -677,7 +677,7 @@ export def commands [
|
||||
...command: string@"nu-complete list-commands" # the name of command to get help on
|
||||
--find (-f): string # string to find in command names and usage
|
||||
] {
|
||||
let commands = ($nu.scope.commands | where not is_extern | reject is_extern | sort-by name)
|
||||
let commands = (scope commands | where not is_extern | reject is_extern | sort-by name)
|
||||
|
||||
if not ($find | is-empty) {
|
||||
# TODO: impl find for external commands
|
||||
|
Reference in New Issue
Block a user