feat: add confirm arg

This commit is contained in:
fzdwx 2023-08-12 21:16:56 +08:00
parent 8f7c8ffbfb
commit 085c003b1b
2 changed files with 6 additions and 3 deletions

View file

@ -108,6 +108,7 @@ impl Executor {
"rename" => cx.manager.rename(),
"shell" => cx.manager.shell(
exec.named.contains_key("block"),
exec.named.contains_key("confirm"),
exec.args.get(0).map(|s| s.as_str()).unwrap_or(""),
),
"hidden" => cx.manager.current_mut().hidden(match exec.args.get(0).map(|s| s.as_str()) {

View file

@ -225,12 +225,14 @@ impl Manager {
pub fn bulk_rename(&self) -> bool { false }
pub fn shell(&self, block: bool, arg: &str) -> bool {
pub fn shell(&self, block: bool, confirm: bool, arg: &str) -> bool {
let mut command = arg.to_string();
tokio::spawn(async move {
if command.is_empty() {
let result = emit!(Input(InputOpt::top("Shell:").with_highlight()));
if confirm || command.is_empty() {
let opt = InputOpt::top("Shell:").with_value(command.as_str()).with_highlight();
let result = emit!(Input(opt));
if let Ok(exec) = result.await {
command = exec;
}