nushell/crates/nu-cmd-lang/src/core_commands
Darren Schroeder 7636963732
add attr category @category to custom command attributes (#15137)
# Description

This PR adds the `@category` attribute to nushell for use with custom
commands.

### Example Code
```nushell
# Some example with category
@category "math"
@search-terms "addition"
@example "add two numbers together" {
    blah 5 6
} --result 11
def blah [
  a: int # First number to add
  b: int # Second number to add
  ] {
    $a + $b
}
```
#### Source & Help
```nushell
❯ source blah.nu
❯ help blah
Some example with category

Search terms: addition

Usage:
  > blah <a> <b>

Flags:
  -h, --help: Display the help message for this command

Parameters:
  a <int>: First number to add
  b <int>: Second number to add

Input/output types:
  ╭─#─┬─input─┬─output─╮
  │ 0 │ any   │ any    │
  ╰───┴───────┴────────╯

Examples:
  add two numbers together
  > blah 5 6
  11
```
#### Show the category
```nushell
❯ help commands | where name == blah
╭─#─┬─name─┬─category─┬─command_type─┬────────description─────────┬─────params─────┬──input_output──┬─search_terms─┬─is_const─╮
│ 0 │ blah │ math     │ custom       │ Some example with category │ [table 3 rows] │ [list 0 items] │ addition     │ false    │
╰───┴──────┴──────────┴──────────────┴────────────────────────────┴────────────────┴────────────────┴──────────────┴──────────╯
```

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# 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` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use toolkit.nu; toolkit test stdlib"` 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.
-->

/cc @Bahex
2025-02-18 15:35:52 -06:00
..
attr add attr category @category to custom command attributes (#15137) 2025-02-18 15:35:52 -06:00
overlay Enable conditional source and use patterns by allowing null as a no-op module (#14773) 2025-01-09 06:37:27 -06:00
scope Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
alias.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
break_.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
collect.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
const_.rs feat(const): implement run_const for const (#15082) 2025-02-12 16:59:51 +01:00
continue_.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
def.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
describe.rs Start to Add WASM Support Again (#14418) 2024-11-30 07:57:11 -06:00
do_.rs Refactor I/O Errors (#14927) 2025-01-28 16:03:31 -06:00
echo.rs make echo const (#14997) 2025-02-06 06:56:30 -06:00
error_make.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
export_alias.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
export_const.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
export_def.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
export_extern.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
export_module.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
export_use.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
export.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
extern_.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
for_.rs Error on non-zero exit statuses (#13515) 2024-09-07 06:44:26 +00:00
hide_env.rs Add search terms for hide and hide-env (#15017) 2025-02-05 23:33:49 -05:00
hide.rs Add search terms for hide and hide-env (#15017) 2025-02-05 23:33:49 -05:00
if_.rs Error on non-zero exit statuses (#13515) 2024-09-07 06:44:26 +00:00
ignore.rs Start to Add WASM Support Again (#14418) 2024-11-30 07:57:11 -06:00
let_.rs Fix try not working with let, etc. (#13885) 2024-09-23 06:44:25 -05:00
loop_.rs Error on non-zero exit statuses (#13515) 2024-09-07 06:44:26 +00:00
match_.rs Error on non-zero exit statuses (#13515) 2024-09-07 06:44:26 +00:00
mod.rs Custom command attributes (#14906) 2025-02-11 06:34:51 -06:00
module.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
mut_.rs Fix try not working with let, etc. (#13885) 2024-09-23 06:44:25 -05:00
return_.rs Replace "function" with "command" in several user-facing doc (#15129) 2025-02-17 14:10:38 -05:00
try_.rs Add label rendering to try/catch rendered errors (#14477) 2024-11-29 19:02:26 -06:00
use_.rs Enable conditional source and use patterns by allowing null as a no-op module (#14773) 2025-01-09 06:37:27 -06:00
version.rs Start to Add WASM Support Again (#14418) 2024-11-30 07:57:11 -06:00
while_.rs Error on non-zero exit statuses (#13515) 2024-09-07 06:44:26 +00:00