mirror of
https://github.com/nushell/nushell
synced 2025-01-18 16:14:10 +00:00
4de0347fdc
# Description `help externs` - command, which list external commands Closes https://github.com/nushell/nushell/issues/8301 # User-Facing Changes ```nu $ 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](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date.
75 lines
1.6 KiB
Rust
75 lines
1.6 KiB
Rust
use nu_protocol::engine::{EngineState, StateWorkingSet};
|
|
|
|
use crate::*;
|
|
|
|
pub fn create_default_context() -> EngineState {
|
|
let mut engine_state = EngineState::new();
|
|
|
|
let delta = {
|
|
let mut working_set = StateWorkingSet::new(&engine_state);
|
|
|
|
macro_rules! bind_command {
|
|
( $( $command:expr ),* $(,)? ) => {
|
|
$( working_set.add_decl(Box::new($command)); )*
|
|
};
|
|
}
|
|
|
|
// Core
|
|
bind_command! {
|
|
Alias,
|
|
Break,
|
|
Commandline,
|
|
Const,
|
|
Continue,
|
|
Def,
|
|
DefEnv,
|
|
Describe,
|
|
Do,
|
|
Echo,
|
|
ErrorMake,
|
|
ExportAlias,
|
|
ExportCommand,
|
|
ExportDef,
|
|
ExportDefEnv,
|
|
ExportExtern,
|
|
ExportUse,
|
|
Extern,
|
|
For,
|
|
Help,
|
|
HelpAliases,
|
|
HelpCommands,
|
|
HelpModules,
|
|
HelpExterns,
|
|
HelpOperators,
|
|
Hide,
|
|
HideEnv,
|
|
If,
|
|
Ignore,
|
|
Overlay,
|
|
OverlayUse,
|
|
OverlayList,
|
|
OverlayNew,
|
|
OverlayHide,
|
|
Let,
|
|
Loop,
|
|
Module,
|
|
Mut,
|
|
Return,
|
|
Try,
|
|
Use,
|
|
Version,
|
|
While,
|
|
};
|
|
|
|
//#[cfg(feature = "plugin")]
|
|
bind_command!(Register);
|
|
|
|
working_set.render()
|
|
};
|
|
|
|
if let Err(err) = engine_state.merge_delta(delta) {
|
|
eprintln!("Error creating default context: {err:?}");
|
|
}
|
|
|
|
engine_state
|
|
}
|