From de856d5e43ecadcd876bdf03800ecc5421347872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Thu, 15 Oct 2020 20:52:27 +0200 Subject: initial cli --- mumctl/Cargo.toml | 7 +++++-- mumctl/src/main.rs | 32 +++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 3 deletions(-) (limited to 'mumctl') diff --git a/mumctl/Cargo.toml b/mumctl/Cargo.toml index fca5037..3a432d9 100644 --- a/mumctl/Cargo.toml +++ b/mumctl/Cargo.toml @@ -9,7 +9,10 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +mumlib = { path = "../mumlib" } + +log = "0.4" +ipc-channel = "0.14" + #clap = "2.33" #cursive = "0.15" -#ipc-channel = "0.14" -#serde = { version = "1.0", features = ["derive"] } diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs index e7a11a9..403447f 100644 --- a/mumctl/src/main.rs +++ b/mumctl/src/main.rs @@ -1,3 +1,33 @@ +use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; +use log::*; +use mumlib::command::{Command, CommandResponse}; +use mumlib::setup_logger; +use std::fs; + fn main() { - println!("Hello, world!"); + setup_logger(); + + // MUMCTL + //temp send command and channel to listener + debug!("Creating channel"); + let (tx_client, rx_client): (IpcSender, ()>>, + IpcReceiver, ()>>) = ipc::channel().unwrap(); + + let server_name = fs::read_to_string("/var/tmp/mumd-oneshot").unwrap(); //TODO don't panic + debug!("Connecting to mumd at {}", server_name); + let tx0 = IpcSender::connect(server_name).unwrap(); + let connect_command = Command::ServerConnect { + host: "10.0.0.10".to_string(), + port: 64738u16, + username: "gustav-mumd".to_string(), + accept_invalid_cert: true, + }; + debug!("Sending {:?} to mumd", connect_command); + tx0.send(( + connect_command, + tx_client)) .unwrap(); + + debug!("Reading response"); + let response = rx_client.recv().unwrap(); + debug!("{:?}", response); } -- cgit v1.2.1