module
For core.
Define a custom module.
Command Type
keyword
Signature
> module {flags} (module) (block)
Parameters
module: Module name or module path.block: Body of the module if ‘module’ parameter is not a module path.
Input/output types:
| input | output |
|---|---|
| nothing | nothing |
Examples
Define a custom command in a module and call it.
> module spam { export def foo [] { "foo" } }; use spam foo; foo
foo
Define an environment variable in a module.
> module foo { export-env { $env.FOO = "BAZ" } }; use foo; $env.FOO
BAZ
Define a custom command that participates in the environment in a module and call it.
> module foo { export def --env bar [] { $env.FOO_BAR = "BAZ" } }; use foo bar; bar; $env.FOO_BAR
BAZ
Notes
This command is a parser keyword. For details, check: https://www.nushell.sh/book/thinking_in_nu.html
Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.