changeset 5:ef523e637b3e

Always print help if --help is given
author Lewin Bormann <lbo@spheniscida.de>
date Sun, 14 Feb 2016 12:06:20 +0100
parents f8842de8ddef
children ec5eb5bac52c
files src/framework.rs src/main.rs
diffstat 2 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/framework.rs	Sun Feb 14 12:03:17 2016 +0100
+++ b/src/framework.rs	Sun Feb 14 12:06:20 2016 +0100
@@ -82,11 +82,10 @@
         ActiveMetric {
             name: name,
             m: metric,
-            st: initial_state
+            st: initial_state,
         }
     }
     pub fn name(&self) -> &String {
         &self.name
     }
 }
-
--- a/src/main.rs	Sun Feb 14 12:03:17 2016 +0100
+++ b/src/main.rs	Sun Feb 14 12:06:20 2016 +0100
@@ -60,7 +60,13 @@
                 self.print_help();
                 process::exit(1)
             }
-            Ok(m) => m,
+            Ok(m) => {
+                if m.opt_present("help") || m.opt_present("h") {
+                    self.print_help();
+                    process::exit(1)
+                }
+                m
+            }
         }
     }
 
@@ -87,10 +93,7 @@
         for (metric_name, metric) in self.metrics.into_iter() {
             if matches.opt_present(&metric_name) {
                 let st = metric.init(matches.opt_str(&metric_name));
-                metrics.push(ActiveMetric::new(
-                    String::from(metric_name),
-                    metric,
-                    st));
+                metrics.push(ActiveMetric::new(String::from(metric_name), metric, st));
             }
         }
 
@@ -119,4 +122,6 @@
     let args: Vec<String> = env::args().collect();
     let all_metrics = AvailableMetrics::new();
     let (selected_metrics, interval) = all_metrics.evaluate(&args[1..]);
+
+    println!("{}", interval);
 }