From bc2075d0885a512f5ec86bc24bf9f48ed1459892 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 1 Nov 2016 16:08:39 +0100 Subject: [PATCH] Add App::app_name() getter --- src/app/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/app/mod.rs b/src/app/mod.rs index 32e66d0d7b4..6374bc57227 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -83,6 +83,16 @@ impl<'a, 'b> App<'a, 'b> { App { p: Parser::with_name(n.into()) } } + /// Get the name of the app + pub fn get_name(&self) -> &str { + &self.p.meta.name + } + + /// Get the name of the binary + pub fn get_bin_name(&self) -> Option<&str> { + self.p.meta.bin_name.as_ref().map(|s| s.as_str()) + } + /// Creates a new instance of an application requiring a name, but uses the [`crate_authors!`] /// and [`crate_version!`] macros to fill in the [`App::author`] and [`App::version`] fields. ///