forked from nushell/nushell
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move CLI related commands to
nu-cli
(nushell#8832)
# Description Part of the larger cratification effort. Moves all `reedline` or shell line editor specific commands to `nu-cli`. ## From `nu-cmd-lang`: - `commandline` - This shouldn't have moved there. Doesn't directly depend on reedline but assumes parts in the engine state that are specific to the use of reedline or a REPL ## From `nu-command`: - `keybindings` and subcommands - `keybindings default` - `keybindings list` - `keybindings listen` - very `reedline` specific - `history` - needs `reedline` - `history session` ## internal use Instead of having a separate `create_default_context()` that calls `nu-command`'s `create_default_context()`, I added a `add_cli_context()` that updates an `EngineState` # User-Facing Changes None ## Build time comparison `cargo build --timings` from a `cargo clean --profile dev` ### total main: 64 secs this: 59 secs ### `nu-command` build time branch | total| codegen | fraction ---|---|---|--- main | 14.0s | 6.2s | (44%) this | 12.5s | 5.5s | (44%) `nu-cli` depends on `nu-command` at the moment. Thus it is built during the code-gen phase of `nu-command` (on 16 virtual cores) # Tests + Formatting I removed the `test_example()` facilities for now as we had not run any of the commands in an `Example` test and importing the right context for those tests seemed more of a hassle than the duplicated `test_examples()` implementations in `nu-cmd-lang` and `nu-command`
- Loading branch information
1 parent
58b96fd
commit 57510f2
Showing
22 changed files
with
49 additions
and
33 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use nu_protocol::engine::{EngineState, StateWorkingSet}; | ||
|
||
use crate::commands::*; | ||
|
||
pub fn add_cli_context(mut engine_state: EngineState) -> EngineState { | ||
let delta = { | ||
let mut working_set = StateWorkingSet::new(&engine_state); | ||
|
||
macro_rules! bind_command { | ||
( $( $command:expr ),* $(,)? ) => { | ||
$( working_set.add_decl(Box::new($command)); )* | ||
}; | ||
} | ||
|
||
bind_command! { | ||
Commandline, | ||
History, | ||
HistorySession, | ||
Keybindings, | ||
KeybindingsDefault, | ||
KeybindingsList, | ||
KeybindingsListen, | ||
}; | ||
|
||
working_set.render() | ||
}; | ||
|
||
if let Err(err) = engine_state.merge_delta(delta) { | ||
eprintln!("Error creating default context: {err:?}"); | ||
} | ||
|
||
engine_state | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...and/src/platform/reedline_commands/mod.rs → crates/nu-cli/src/commands/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
mod commandline; | ||
mod default_context; | ||
mod history; | ||
mod history_session; | ||
mod keybindings; | ||
mod keybindings_default; | ||
mod keybindings_list; | ||
mod keybindings_listen; | ||
|
||
pub use commandline::Commandline; | ||
pub use history::History; | ||
pub use history_session::HistorySession; | ||
pub use keybindings::Keybindings; | ||
pub use keybindings_default::KeybindingsDefault; | ||
pub use keybindings_list::KeybindingsList; | ||
pub use keybindings_listen::KeybindingsListen; | ||
|
||
pub use default_context::add_cli_context; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
mod history; | ||
mod history_session; | ||
mod tutor; | ||
|
||
pub use history::History; | ||
pub use history_session::HistorySession; | ||
pub use tutor::Tutor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters