Initial commit
This commit is contained in:
commit
264acc6645
4 changed files with 46 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
/target
|
||||||
10
Cargo.toml
Normal file
10
Cargo.toml
Normal file
|
|
@ -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"
|
||||||
6
auto_test.sh
Executable file
6
auto_test.sh
Executable file
|
|
@ -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"
|
||||||
29
src/main.rs
Normal file
29
src/main.rs
Normal file
|
|
@ -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 <harald.kube@gmx.de")
|
||||||
|
(about: "Listen for S0 pulses at the given GPIO pins")
|
||||||
|
(@arg v: -v ... "Set the verbosity level (up to -vvv)")
|
||||||
|
(@arg config: -c --config +takes_value "The name of the config file (default: /etc/s0_logger.cfg)")
|
||||||
|
).get_matches();
|
||||||
|
|
||||||
|
let log_level = cli_args.occurrences_of("v");
|
||||||
|
match log_level {
|
||||||
|
0 => 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);
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue