summaryrefslogtreecommitdiffstats
path: root/src/verb/external_execution.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2021-04-08 17:22:30 +0200
committerCanop <cano.petrole@gmail.com>2021-04-15 13:00:23 +0200
commit831c10d6c5ccf74d0109b6bc3ffd708a9da61cab (patch)
tree1435f23e6f19549e49f01e52f4cbfc702ec3a06b /src/verb/external_execution.rs
parentacade5051d04d14509b5526f48b1bb9de2ee4f70 (diff)
staging area [WIP]
The staging area will be the way to operate on multiple files. See issue #266 (it's far from ready)
Diffstat (limited to 'src/verb/external_execution.rs')
-rw-r--r--src/verb/external_execution.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/verb/external_execution.rs b/src/verb/external_execution.rs
index 651ad3c..30868ef 100644
--- a/src/verb/external_execution.rs
+++ b/src/verb/external_execution.rs
@@ -84,11 +84,16 @@ impl ExternalExecution {
writeln!(&f, "{}", builder.shell_exec_string(&self.exec_pattern))?;
Ok(CmdResult::Quit)
} else if let Some(ref export_path) = con.launch_args.file_export_path {
- // old version of the br function: only the file is exported
- // in the passed file
- let f = OpenOptions::new().append(true).open(export_path)?;
- writeln!(&f, "{}", builder.sel.path.to_string_lossy())?;
- Ok(CmdResult::Quit)
+ if let Some(sel) = builder.sel {
+ // old version of the br function: only the file is exported
+ // in the passed file
+ let f = OpenOptions::new().append(true).open(export_path)?;
+ writeln!(&f, "{}", sel.path.to_string_lossy())?;
+ Ok(CmdResult::Quit)
+ } else {
+ // should not happen
+ Ok(CmdResult::error("no selection"))
+ }
} else {
Ok(CmdResult::DisplayError(
"this verb needs broot to be launched as `br`. Try `broot --install` if necessary."
@@ -108,7 +113,7 @@ impl ExternalExecution {
let launchable = Launchable::program(
builder.exec_token(&self.exec_pattern),
if self.set_working_dir {
- Some(path::closest_dir(builder.sel.path))
+ builder.sel.map(|sel| path::closest_dir(sel.path))
} else {
None
},