diff --git a/Cargo.toml b/Cargo.toml index 971026a..7d4e4e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,4 +2,5 @@ members = [ "candid_server", "candid_client", + "candid_cli", ] diff --git a/candid_cli/Cargo.toml b/candid_cli/Cargo.toml new file mode 100644 index 0000000..647d693 --- /dev/null +++ b/candid_cli/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "candid_cli" +version = "0.1.0" +authors = ["Alex van de Sandt "] +edition = "2018" +description = "" +license = "MIT" +readme = "README" +documentation = "https://docs.rs/crate/candid_client/" +repository = "https://gitlab.com/avandesa/candid-rs" +keywords = ["CAN", "SocketCAN"] + +[dependencies] +candid_client = "^0.1" +clap = "^2.32" diff --git a/candid_cli/src/main.rs b/candid_cli/src/main.rs new file mode 100644 index 0000000..33909b1 --- /dev/null +++ b/candid_cli/src/main.rs @@ -0,0 +1,27 @@ +use candid_client::*; + +use clap::{App, Arg}; + +fn main() { + let matches = App::new("CANdid Client") + .version("0.1.0") + .author("Alex van de Sandt ") + .about("A client to read messages from a CANdid server") + .arg( + Arg::with_name("addr") + .value_name("ADDRESS") + .help("The address:port to connect to") + .takes_value(true) + .required(true), + ) + .get_matches(); + + let addr = matches.value_of("addr").unwrap(); + + let client = CandidConnection::new(addr).expect("Couldn't connect to server"); + + for line in client.lines() { + let line = line.unwrap(); + println!("Received: \"{}\"", line); + } +}