|
|
@ -11,7 +11,8 @@ use xplr::app;
|
|
|
|
struct Cli {
|
|
|
|
struct Cli {
|
|
|
|
version: bool,
|
|
|
|
version: bool,
|
|
|
|
help: bool,
|
|
|
|
help: bool,
|
|
|
|
path: Option<String>,
|
|
|
|
path: Option<PathBuf>,
|
|
|
|
|
|
|
|
config: Option<PathBuf>,
|
|
|
|
on_load: Vec<app::ExternalMsg>,
|
|
|
|
on_load: Vec<app::ExternalMsg>,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -41,12 +42,14 @@ impl Cli {
|
|
|
|
|
|
|
|
|
|
|
|
"--" => {
|
|
|
|
"--" => {
|
|
|
|
if cli.path.is_none() {
|
|
|
|
if cli.path.is_none() {
|
|
|
|
cli.path = args.pop_front();
|
|
|
|
cli.path = args.pop_front().map(PathBuf::from);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Ok(cli);
|
|
|
|
return Ok(cli);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Options
|
|
|
|
// Options
|
|
|
|
|
|
|
|
"-c" | "--config" => cli.config = args.pop_front().map(PathBuf::from),
|
|
|
|
|
|
|
|
|
|
|
|
"--on-load" => {
|
|
|
|
"--on-load" => {
|
|
|
|
while let Some(msg) = args.pop_front() {
|
|
|
|
while let Some(msg) = args.pop_front() {
|
|
|
|
if msg.starts_with('-') {
|
|
|
|
if msg.starts_with('-') {
|
|
|
@ -81,13 +84,15 @@ fn main() {
|
|
|
|
xplr [FLAG]... [OPTION]... [PATH]"###;
|
|
|
|
xplr [FLAG]... [OPTION]... [PATH]"###;
|
|
|
|
|
|
|
|
|
|
|
|
let flags = r###"
|
|
|
|
let flags = r###"
|
|
|
|
- Read PATH from stdin
|
|
|
|
- Read path from stdin
|
|
|
|
-- End of flags and options
|
|
|
|
-- End of flags and options
|
|
|
|
-h, --help Prints help information
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information"###;
|
|
|
|
-V, --version Prints version information"###;
|
|
|
|
|
|
|
|
|
|
|
|
let options = r###"
|
|
|
|
let options = r###"
|
|
|
|
--on-load <MESSAGE>... Send messages when xplr loads"###;
|
|
|
|
-c, --config <PATH> Specifies a custom config file (default is
|
|
|
|
|
|
|
|
"$HOME/.config/xplr/init.lua")
|
|
|
|
|
|
|
|
--on-load <MESSAGE>... Sends messages when xplr loads"###;
|
|
|
|
|
|
|
|
|
|
|
|
let args = r###"
|
|
|
|
let args = r###"
|
|
|
|
<PATH> Path to focus on, or enter if directory"###;
|
|
|
|
<PATH> Path to focus on, or enter if directory"###;
|
|
|
@ -108,8 +113,9 @@ fn main() {
|
|
|
|
} else if cli.version {
|
|
|
|
} else if cli.version {
|
|
|
|
println!("xplr {}", xplr::app::VERSION);
|
|
|
|
println!("xplr {}", xplr::app::VERSION);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
match app::runner(cli.path.as_ref().map(PathBuf::from))
|
|
|
|
match app::runner(cli.path.clone())
|
|
|
|
.map(|a| a.with_on_load(cli.on_load))
|
|
|
|
.map(|a| a.with_on_load(cli.on_load.clone()))
|
|
|
|
|
|
|
|
.map(|a| a.with_config(cli.config))
|
|
|
|
.and_then(|a| a.run())
|
|
|
|
.and_then(|a| a.run())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Ok(Some(out)) => print!("{}", out),
|
|
|
|
Ok(Some(out)) => print!("{}", out),
|
|
|
|