add command-line option to test idle commands and exit
struct CircadianLaunchOptions {
config_file: String,
//script_dir: String,
+ test: bool,
}
#[derive(Default,Debug)]
.about(env!("CARGO_PKG_DESCRIPTION"))
.args_from_usage(
"-f, --config=[FILE] ''
+ -t, --test 'Run idle tests and exit'
-d, --script-dir=[DIR] ''")
.get_matches();
let config = matches.value_of("config").unwrap_or("/etc/circadian.conf");
CircadianLaunchOptions {
config_file: config.to_owned(),
//script_dir: script_dir.to_owned(),
+ test: matches.is_present("test"),
}
}
});
println!("{:?}", config);
+ if launch_opts.test {
+ println!("Got --test: running idle test and exiting.");
+ let start = time::now_utc().to_timespec().sec as i64;
+ let idle = test_idle(&config, start);
+ let tests = test_nonidle(&config);
+ println!("Idle Detection Summary:\n{}{}", idle, tests);
+ std::process::exit(0);
+ }
+
if !config.tty_input && !config.x11_input {
println!("tty_input or x11_input must be enabled. Exiting.");
std::process::exit(1);