summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-02-28 15:31:47 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-02-28 15:31:53 +0100
commit345c544a2b5691941542742adaf57767269be1a8 (patch)
treeb55ff2c6b4d235d8da02538b15f973e8b41fad3a
parent3c241444e8b6e1ecbc4a09cd40eca755f3cf60d3 (diff)
parenta3227e0a947a7cc76b01b0365f962b3b6e2fea1e (diff)
Merge branch 'imag-unstable' into master
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--bin/core/imag/src/main.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/bin/core/imag/src/main.rs b/bin/core/imag/src/main.rs
index 41757929..d08f2191 100644
--- a/bin/core/imag/src/main.rs
+++ b/bin/core/imag/src/main.rs
@@ -142,12 +142,17 @@ fn get_commands() -> Result<Vec<String>> {
fn main() -> Result<()> {
// Initialize the Runtime and build the CLI
- let appname = "imag";
+ let appname = ::std::env::current_exe()?
+ .file_name()
+ .ok_or_else(|| format_err!("Program is not a file. This is a BUG, please file me."))?
+ .to_str()
+ .ok_or_else(|| format_err!("Program name is not UTF8. Whut?"))?
+ .to_string();
let version = make_imag_version!();
let about = "imag - the PIM suite for the commandline";
let commands = get_commands()?;
let helptext = help_text(commands.clone());
- let mut app = Runtime::get_default_cli_builder(appname, &version, about)
+ let mut app = Runtime::get_default_cli_builder(&appname, &version, about)
.settings(&[AppSettings::AllowExternalSubcommands, AppSettings::ArgRequiredElseHelp])
.arg(Arg::with_name("version")
.long("version")
@@ -201,7 +206,7 @@ fn main() -> Result<()> {
commands
.iter()
.map(|command| {
- match Command::new(format!("imag-{}", command))
+ match Command::new(format!("{}-{}", appname, command))
.stdin(::std::process::Stdio::inherit())
.stdout(::std::process::Stdio::piped())
.stderr(::std::process::Stdio::inherit())
@@ -242,10 +247,10 @@ fn main() -> Result<()> {
let subcommand = String::from(subcommand);
let subcommand = aliases.get(&subcommand).cloned().unwrap_or(subcommand);
- debug!("Calling 'imag-{}' with args: {:?}", subcommand, subcommand_args);
+ debug!("Calling '{}-{}' with args: {:?}", appname, subcommand, subcommand_args);
// Create a Command, and pass it the gathered arguments
- match Command::new(format!("imag-{}", subcommand))
+ match Command::new(format!("{}-{}", appname, subcommand))
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())