mirror of
https://github.com/bytedream/docker4ssh.git
synced 2025-05-09 12:15:11 +02:00
Removed compiler warnings
This commit is contained in:
parent
73c24e457a
commit
90da7b4999
@ -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<T> = std::result::Result<T, failure::Error>;
|
||||
|
||||
@ -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<Root>
|
||||
}
|
||||
@ -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 {
|
||||
|
@ -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<ConfigNetworkMode, String> {
|
||||
|
@ -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),
|
||||
|
@ -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<T> = std::result::Result<T, failure::Error>;
|
||||
|
||||
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)
|
||||
|
@ -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};
|
||||
|
@ -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) {}
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user