nushell/crates
Bahex 442df9e39c
Custom command attributes (#14906)
# Description
Add custom command attributes.

- Attributes are placed before a command definition and start with a `@`
character.
- Attribute invocations consist of const command call. The command's
name must start with "attr ", but this prefix is not used in the
invocation.
- A command named `attr example` is invoked as an attribute as
`@example`
-   Several built-in attribute commands are provided as part of this PR
    -   `attr example`: Attaches an example to the commands help text
        ```nushell
        # Double numbers
        @example "double an int"  { 5 | double }   --result 10
        @example "double a float" { 0.5 | double } --result 1.0
        def double []: [number -> number] {
            $in * 2
        }
        ```
    -   `attr search-terms`: Adds search terms to a command
    -   ~`attr env`: Equivalent to using `def --env`~
- ~`attr wrapped`: Equivalent to using `def --wrapped`~ shelved for
later discussion
    -   several testing related attributes in `std/testing`
- If an attribute has no internal/special purpose, it's stored as
command metadata that can be obtained with `scope commands`.
- This allows having attributes like `@test` which can be used by test
runners.
-   Used the `@example` attribute for `std` examples.
-   Updated the std tests and test runner to use `@test` attributes
-   Added completions for attributes

# User-Facing Changes
Users can add examples to their own command definitions, and add other
arbitrary attributes.

# Tests + Formatting

- 🟢 toolkit fmt
- 🟢 toolkit clippy
- 🟢 toolkit test
- 🟢 toolkit test stdlib

# After Submitting
- Add documentation about the attribute syntax and built-in attributes
- `help attributes`

---------

Co-authored-by: 132ikl <132@ikl.sh>
2025-02-11 06:34:51 -06:00
..
nu_plugin_custom_values Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu_plugin_example Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu_plugin_formats Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu_plugin_gstat Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu_plugin_inc Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu_plugin_nu_example Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu_plugin_polars fix polars save example typo (#15008) 2025-02-06 07:01:09 -06:00
nu_plugin_python Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu_plugin_query Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu_plugin_stress_internals Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-cli Custom command attributes (#14906) 2025-02-11 06:34:51 -06:00
nu-cmd-base Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-cmd-extra Refactor/fix tests affecting the whole command set (#15073) 2025-02-11 11:36:36 +01:00
nu-cmd-lang Custom command attributes (#14906) 2025-02-11 06:34:51 -06:00
nu-cmd-plugin Refactor/fix tests affecting the whole command set (#15073) 2025-02-11 11:36:36 +01:00
nu-color-config Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-command Refactor/fix tests affecting the whole command set (#15073) 2025-02-11 11:36:36 +01:00
nu-derive-value Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-engine Custom command attributes (#14906) 2025-02-11 06:34:51 -06:00
nu-explore use 0-indexing in explore (#15079) 2025-02-10 15:26:42 -06:00
nu-glob Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-json Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-lsp fix(lsp): inlay hints span issue with user config scripts (#15071) 2025-02-10 16:15:03 +01:00
nu-parser Custom command attributes (#14906) 2025-02-11 06:34:51 -06:00
nu-path Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-plugin Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-plugin-core Replaced IoError::new_with_additional_context calls that still had Span::unknown() (#15056) 2025-02-08 09:23:28 -06:00
nu-plugin-engine Replaced IoError::new_with_additional_context calls that still had Span::unknown() (#15056) 2025-02-08 09:23:28 -06:00
nu-plugin-protocol Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-plugin-test-support Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-pretty-hex Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-protocol Custom command attributes (#14906) 2025-02-11 06:34:51 -06:00
nu-std Custom command attributes (#14906) 2025-02-11 06:34:51 -06:00
nu-system Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-table Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-term-grid Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nu-test-support fix: clippy warnings with --all-features (#15035) 2025-02-07 12:30:25 +01:00
nu-utils Bump to 0.102.1 dev version (#15012) 2025-02-05 00:19:48 -05:00
nuon Custom command attributes (#14906) 2025-02-11 06:34:51 -06:00
README.md Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00

Nushell core libraries and plugins

These sub-crates form both the foundation for Nu and a set of plugins which extend Nu with additional functionality.

Foundational libraries are split into two kinds of crates:

  • Core crates - those crates that work together to build the Nushell language engine
  • Support crates - a set of crates that support the engine with additional features like JSON support, ANSI support, and more.

Plugins are likewise also split into two types:

  • Core plugins - plugins that provide part of the default experience of Nu, including access to the system properties, processes, and web-connectivity features.
  • Extra plugins - these plugins run a wide range of different capabilities like working with different file types, charting, viewing binary data, and more.