commit 264acc6645a0c670d93fc8fd515debc7f1452644 Author: Harald Kube Date: Thu Feb 11 15:05:10 2021 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..c26dd86 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "s0_meter" +version = "0.1.0" +authors = ["hk"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +clap = "2.33.3" diff --git a/auto_test.sh b/auto_test.sh new file mode 100755 index 0000000..50fb9e3 --- /dev/null +++ b/auto_test.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# Start test if one of the files was modified +cargo install cargo-watch + +RUST_BACKTRACE=full cargo watch -x "test -- --nocapture" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..c64f103 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,29 @@ +#[macro_use] +extern crate clap; + +const APP_VERSION: &'static str = env!("CARGO_PKG_VERSION"); +const DEFAULT_CONFIG_FILE_NAME: &str = "/etc/s0_logger.cfg"; + +fn main() { + let cli_args = clap_app!(s0_meter => + (version: APP_VERSION) + (author: "Harald Kube println!("No logging"), + 1 => println!("A little logging"), + 2 => println!("A little more logging"), + _ => println!("A lot logging"), + }; + + let config_file_name = cli_args + .value_of("config") + .unwrap_or(DEFAULT_CONFIG_FILE_NAME); + println!("Read the config from file '{}'", config_file_name); + +}