diff --git a/CHANGELOG.md b/CHANGELOG.md index f57de69..afdf7de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Nushell: Added alias support - Also allows arbitrary shell to provide support +- `echo` mode: Only print suggestion ### Fixed diff --git a/core/src/main.rs b/core/src/main.rs index 09cb604..23dc638 100644 --- a/core/src/main.rs +++ b/core/src/main.rs @@ -54,6 +54,7 @@ fn main() -> Result<(), std::io::Error> { use shell::Mode::*; match data.mode { Suggestion => modes::suggestion(&mut data), + Echo => modes::echo(&mut data), Cnf => modes::cnf(&mut data), } diff --git a/core/src/modes.rs b/core/src/modes.rs index 5250c2d..118a8df 100644 --- a/core/src/modes.rs +++ b/core/src/modes.rs @@ -54,6 +54,18 @@ pub fn suggestion(data: &mut Data) { ); } +pub fn echo(data: &mut Data) { + let shell = data.shell.clone(); + suggest_candidates(data); + if data.candidates.is_empty() { + eprintln!("No suggestions found") + }; + for candidate in &mut data.candidates { + shell::shell_syntax(&shell, candidate); + println!("{} <_PR_BR>", candidate); + } +} + pub fn cnf(data: &mut Data) { let shell = data.shell.clone(); let mut split_command = data.split.clone(); diff --git a/core/src/shell.rs b/core/src/shell.rs index ad0b6bd..03b7df1 100644 --- a/core/src/shell.rs +++ b/core/src/shell.rs @@ -17,6 +17,7 @@ pub const PRIVILEGE_LIST: [&str; 2] = ["sudo", "doas"]; #[derive(PartialEq)] pub enum Mode { Suggestion, + Echo, Cnf, } pub struct Init { @@ -382,7 +383,11 @@ pub fn run_mode() -> Mode { Ok(mode) => match mode.as_str() { "suggestion" => Mode::Suggestion, "cnf" => Mode::Cnf, - _ => Mode::Suggestion, + "echo" => Mode::Echo, + _ => { + eprintln!("Invalid mode: {}", mode); + exit(1); + } }, Err(_) => Mode::Suggestion, }