forked from extern/nushell
fix: fix commandline
when called with no arguments (#8207)
# Description This fixes the `commandline` command when it's run with no arguments, so it outputs the command being run. New line characters are included. This allows for: - [A way to get current command inside pre_execution hook · Issue #6264 · nushell/nushell](https://github.com/nushell/nushell/issues/6264) - The possibility of *Atuin* to work work *Nushell*. *Atuin* hooks need to know the current repl input before it is run. # User-Facing 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 -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.
This commit is contained in:
@ -13,7 +13,7 @@ use std::num::NonZeroUsize;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::{
|
||||
collections::{HashMap, HashSet, VecDeque},
|
||||
collections::{HashMap, HashSet},
|
||||
sync::{
|
||||
atomic::{AtomicBool, AtomicU32},
|
||||
Arc, Mutex,
|
||||
@ -22,15 +22,6 @@ use std::{
|
||||
|
||||
static PWD_ENV: &str = "PWD";
|
||||
|
||||
// TODO: move to different file? where?
|
||||
/// An operation to be performed with the current buffer of the interactive shell.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ReplOperation {
|
||||
Append(String),
|
||||
Insert(String),
|
||||
Replace(String),
|
||||
}
|
||||
|
||||
/// Organizes usage messages for various primitives
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Usage {
|
||||
@ -134,8 +125,9 @@ pub struct EngineState {
|
||||
pub previous_env_vars: HashMap<String, Value>,
|
||||
pub config: Config,
|
||||
pub pipeline_externals_state: Arc<(AtomicU32, AtomicU32)>,
|
||||
pub repl_buffer_state: Arc<Mutex<Option<String>>>,
|
||||
pub repl_operation_queue: Arc<Mutex<VecDeque<ReplOperation>>>,
|
||||
pub repl_buffer_state: Arc<Mutex<String>>,
|
||||
// A byte position, as `EditCommand::MoveToPosition` is also a byte position
|
||||
pub repl_cursor_pos: Arc<Mutex<usize>>,
|
||||
#[cfg(feature = "plugin")]
|
||||
pub plugin_signatures: Option<PathBuf>,
|
||||
#[cfg(not(windows))]
|
||||
@ -186,8 +178,8 @@ impl EngineState {
|
||||
previous_env_vars: HashMap::new(),
|
||||
config: Config::default(),
|
||||
pipeline_externals_state: Arc::new((AtomicU32::new(0), AtomicU32::new(0))),
|
||||
repl_buffer_state: Arc::new(Mutex::new(None)),
|
||||
repl_operation_queue: Arc::new(Mutex::new(VecDeque::new())),
|
||||
repl_buffer_state: Arc::new(Mutex::new("".to_string())),
|
||||
repl_cursor_pos: Arc::new(Mutex::new(0)),
|
||||
#[cfg(feature = "plugin")]
|
||||
plugin_signatures: None,
|
||||
#[cfg(not(windows))]
|
||||
|
Reference in New Issue
Block a user