No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lib.rs 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #[macro_use]
  2. extern crate clap;
  3. use clap::App;
  4. /// Datentyp zur Beschreibung der Konfiguration des Servers.
  5. pub struct Config {
  6. pub address: String,
  7. pub port: String,
  8. pub verbosity: u64,
  9. pub testing: bool,
  10. }
  11. impl Config {
  12. /// Funktion zum Lesen der Konfigurationsdatei des Servers.
  13. pub fn load() -> Self {
  14. let yaml = load_yaml!("cli.yml");
  15. let matches = App::from_yaml(yaml).get_matches();
  16. let address = matches.value_of("address").unwrap_or("127.0.0.1");
  17. let port = matches.value_of("port").unwrap_or("7878");
  18. let verbosity = matches.occurrences_of("verbose");
  19. let mut testing = false;
  20. // Falls das Unterkommando timings angegeben wurde aktiviere die Zeitmessung.
  21. if let Some(ref sub_command) = matches.subcommand {
  22. if sub_command.name.eq("test") {
  23. testing = true;
  24. }
  25. }
  26. Config {
  27. address: address.to_string(),
  28. port: port.to_string(),
  29. verbosity: verbosity,
  30. testing: testing,
  31. }
  32. }
  33. }