Implement --force-focus

This commit is contained in:
Tom van Dijk 2021-10-29 16:43:05 +02:00 committed by Arijit Basu
parent 3c8de699ca
commit 44f05c6e4b
2 changed files with 14 additions and 1 deletions

View File

@ -27,7 +27,8 @@ fn main() {
"$HOME/.config/xplr/init.lua")
-C, --extra-config <PATH>... Specifies extra config files to load
--on-load <MESSAGE>... Sends messages when xplr loads
--select <FILE> Selects the given paths."###;
--select <FILE> Selects the given paths.
--force-focus Focuses the given path, instead of entering it."###;
let args = r###"
<PATH> Path to focus on, or enter if directory"###;

View File

@ -87,6 +87,18 @@ impl Cli {
}
}
"--force-focus" => {
let path = cli
.path
.as_ref()
.map(|x| x.clone())
.or(args.pop_front().map(PathBuf::from))
.unwrap_or(PathBuf::new());
cli.on_load.push(app::ExternalMsg::FocusPath(
path.to_string_lossy().to_string(),
));
}
// path
path => {
if cli.path.is_none() {