diff --git a/container/src/configure/cli/cli.rs b/container/src/configure/cli/cli.rs index d9432fc..cb46ad2 100644 --- a/container/src/configure/cli/cli.rs +++ b/container/src/configure/cli/cli.rs @@ -1,7 +1,4 @@ -use std::fmt::{Debug, format}; -use std::net::TcpStream; -use std::os::unix::process::ExitStatusExt; -use std::process::{Command, ExitStatus}; +use std::process::Command; use std::time::SystemTime; use log::{info, warn}; use structopt::StructOpt; @@ -9,7 +6,7 @@ use structopt::clap::AppSettings; use crate::configure::cli::parser; use crate::shared::api::api::API; use crate::shared::api::request; -use crate::shared::api::request::{ConfigGetResponse, ConfigNetworkMode, ConfigPostRequest, ConfigRunLevel}; +use crate::shared::api::request::{ConfigGetResponse, ConfigNetworkMode, ConfigRunLevel}; type Result = std::result::Result; @@ -24,9 +21,6 @@ trait Execute { settings = &[AppSettings::ArgRequiredElseHelp] )] struct Opts { - #[structopt(short, long, global = true, help = "Verbose output")] - verbose: bool, - #[structopt(subcommand)] commands: Option } @@ -259,7 +253,7 @@ enum Root { pub fn cli(route: String) { if let Some(subcommand) = Opts::from_args().commands { let mut result: Result<()> = Ok(()); - let mut api = API::new(route, String::new()); + let mut api = API::new(route); match subcommand { Root::Auth(auth) => { if let Some(subsubcommand) = auth.commands { diff --git a/container/src/configure/cli/parser.rs b/container/src/configure/cli/parser.rs index e9c6c59..859e91e 100644 --- a/container/src/configure/cli/parser.rs +++ b/container/src/configure/cli/parser.rs @@ -1,5 +1,3 @@ -use std::f32::consts::E; -use std::fmt::format; use crate::shared::api::request::{ConfigNetworkMode, ConfigRunLevel}; pub fn parse_network_mode(src: &str) -> Result { diff --git a/container/src/configure/main.rs b/container/src/configure/main.rs index 740155f..c21c933 100644 --- a/container/src/configure/main.rs +++ b/container/src/configure/main.rs @@ -1,13 +1,13 @@ use std::fs; -use std::net::TcpStream; -use std::os::unix::net::UnixStream; use std::process::exit; -use log::{LevelFilter, trace, warn, info, error}; +use log::{LevelFilter, error}; use docker4ssh::configure::cli; use docker4ssh::shared::logging::init_logger; fn main() { - init_logger(LevelFilter::Debug); + if init_logger(LevelFilter::Debug).is_err() { + println!("Failed to initialize logger"); + } match fs::read_to_string("/etc/docker4ssh") { Ok(route) => cli(route), diff --git a/container/src/shared/api/api.rs b/container/src/shared/api/api.rs index af76b39..7abe2de 100644 --- a/container/src/shared/api/api.rs +++ b/container/src/shared/api/api.rs @@ -1,21 +1,18 @@ use std::collections::HashMap; use std::io::{Read, Write}; use std::net::TcpStream; -use log::Level::Error; use serde::Deserialize; pub type Result = std::result::Result; pub struct API { route: String, - host: String, } impl API { - pub const fn new(route: String, host: String) -> Self { + pub const fn new(route: String) -> Self { API { route, - host, } } @@ -86,7 +83,7 @@ impl APIResult { let result: T = serde_json::from_str(&self.result_body).map_err(|e| { // checks if the error has a body and if so, return it if self.has_body() { - let error: APIError = serde_json::from_str(&self.result_body).unwrap_or_else(|ee| { + let error: APIError = serde_json::from_str(&self.result_body).unwrap_or_else(|_| { APIError{message: format!("could not deserialize response: {}", e.to_string())} }); failure::format_err!("Failed to call '{}': {}", self.request_path, error.message) diff --git a/container/src/shared/api/request.rs b/container/src/shared/api/request.rs index 75e20c1..73327ee 100644 --- a/container/src/shared/api/request.rs +++ b/container/src/shared/api/request.rs @@ -1,6 +1,5 @@ use std::fmt::{Display, Formatter}; use serde::{Deserialize, Serialize}; -use serde::de::Unexpected::Str; use serde_repr::{Deserialize_repr, Serialize_repr}; use crate::shared::api::api::{API, Method, Request, Result}; diff --git a/container/src/shared/logging/logger.rs b/container/src/shared/logging/logger.rs index 83ccc71..2b9d040 100644 --- a/container/src/shared/logging/logger.rs +++ b/container/src/shared/logging/logger.rs @@ -1,9 +1,9 @@ -use log::{info, Metadata, Record}; +use log::{Metadata, Record}; pub struct Logger; impl log::Log for Logger { - fn enabled(&self, metadata: &Metadata) -> bool { + fn enabled(&self, _metadata: &Metadata) -> bool { true } @@ -13,7 +13,5 @@ impl log::Log for Logger { } } - fn flush(&self) { - todo!() - } + fn flush(&self) {} } diff --git a/container/src/shared/logging/mod.rs b/container/src/shared/logging/mod.rs index 686e189..8fa57ab 100644 --- a/container/src/shared/logging/mod.rs +++ b/container/src/shared/logging/mod.rs @@ -4,8 +4,6 @@ pub mod logger; pub use logger::Logger; -static LOGGER: Logger = Logger; - pub fn init_logger(level: LevelFilter) -> Result<(), SetLoggerError> { log::set_logger(&Logger).map(|()| log::set_max_level(level)) }