diff --git a/src/cli.yml b/src/cli.yml index e6f7823..ee635f5 100644 --- a/src/cli.yml +++ b/src/cli.yml @@ -1,8 +1,8 @@ -name: AdvoTracker -version: "0.0.1" -author: Ralf Zerres -#about: AdvoTracker unterstützt Anwälte bei der Erfassung relevanter Mandatsdaten in einer Online-Beratung -about: AdvoTracker supports lawyers to capture relevant data encountered during an online legal advice +name: myapp +version: "1.0" +author: Networkx GmbH +about: capture relevant data encountered during an online legal advice +after_help: in Zusammenarbeit mit HIEDEMANN Rechtsanwälte args: - config: short: c @@ -10,8 +10,18 @@ args: value_name: FILE help: Sets a custom config file takes_value: true + - dbdriver: + short: D + long: dbdriver + help: Driver used to connect to database + possible_values: + - mysql + - postgres + - sqlite + takes_value: true - verbose: short: v + long: verbose multiple: true help: Sets the level of verbosity subcommands: diff --git a/src/main.rs b/src/main.rs index 082b975..5e40485 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,8 +14,31 @@ fn main() { println!("{}", &res); let yaml = load_yaml!("cli.yml"); - let _matches = App::from_yaml(yaml).get_matches(); + let matches = App::from_yaml(yaml) + .name(crate_name!()) + .version(crate_version!()) + .author(crate_authors!()) + .about(crate_description!()) + .get_matches(); + // Gets a options value if supplied by user. otherwise set defaults + let config = matches.value_of("config").unwrap_or("default.conf"); + println!("Value for config: {}", config); + + let dbdriver = matches.value_of("dbdriver").unwrap_or("sqlite3"); + println!("Value for database driver: {}", dbdriver); + + // Vary the output based on how many times the user used the "verbose" flag + // (i.e. ' -v -v -v' or 'myprog -vvv' vs 'myprog -v' + match matches.occurrences_of("v") { + 0 => println!("No verbose info"), + 1 => println!("Some verbose info"), + 2 => println!("Tons of verbose info"), + 3 | _ => println!("Don't be crazy"), + } + + + // Starting the program logic let res = t!("main.start", lang); println!("{}", &res); }