mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2026-02-02 15:45:11 +01:00
feat: echo mode
This commit is contained in:
parent
ec9609f470
commit
1b018bc763
4 changed files with 20 additions and 1 deletions
|
|
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
- Nushell: Added alias support
|
- Nushell: Added alias support
|
||||||
- Also allows arbitrary shell to provide support
|
- Also allows arbitrary shell to provide support
|
||||||
|
- `echo` mode: Only print suggestion
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ fn main() -> Result<(), std::io::Error> {
|
||||||
use shell::Mode::*;
|
use shell::Mode::*;
|
||||||
match data.mode {
|
match data.mode {
|
||||||
Suggestion => modes::suggestion(&mut data),
|
Suggestion => modes::suggestion(&mut data),
|
||||||
|
Echo => modes::echo(&mut data),
|
||||||
Cnf => modes::cnf(&mut data),
|
Cnf => modes::cnf(&mut data),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
pub fn cnf(data: &mut Data) {
|
||||||
let shell = data.shell.clone();
|
let shell = data.shell.clone();
|
||||||
let mut split_command = data.split.clone();
|
let mut split_command = data.split.clone();
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ pub const PRIVILEGE_LIST: [&str; 2] = ["sudo", "doas"];
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
pub enum Mode {
|
pub enum Mode {
|
||||||
Suggestion,
|
Suggestion,
|
||||||
|
Echo,
|
||||||
Cnf,
|
Cnf,
|
||||||
}
|
}
|
||||||
pub struct Init {
|
pub struct Init {
|
||||||
|
|
@ -382,7 +383,11 @@ pub fn run_mode() -> Mode {
|
||||||
Ok(mode) => match mode.as_str() {
|
Ok(mode) => match mode.as_str() {
|
||||||
"suggestion" => Mode::Suggestion,
|
"suggestion" => Mode::Suggestion,
|
||||||
"cnf" => Mode::Cnf,
|
"cnf" => Mode::Cnf,
|
||||||
_ => Mode::Suggestion,
|
"echo" => Mode::Echo,
|
||||||
|
_ => {
|
||||||
|
eprintln!("Invalid mode: {}", mode);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Err(_) => Mode::Suggestion,
|
Err(_) => Mode::Suggestion,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue