[[package]]
name = "mpd_info_screen"
-version = "0.2.8"
+version = "0.2.9"
dependencies = [
"ggez",
"image",
[package]
name = "mpd_info_screen"
-version = "0.2.8"
+version = "0.2.9"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
# Usage
- mpd_info_screen 0.2.8
+ mpd_info_screen 0.2.9
USAGE:
mpd_info_screen [FLAGS] [OPTIONS] <host> [port]
use std::fmt::Display;
use structopt::clap::arg_enum;
+#[derive(Copy, Clone, Debug, PartialEq)]
+pub enum LogState {
+ ERROR,
+ WARNING,
+ DEBUG,
+ VERBOSE,
+}
+
arg_enum! {
#[derive(Copy, Clone, Debug, PartialEq)]
- pub enum LogState {
+ pub enum LogLevel {
ERROR,
WARNING,
DEBUG,
}
}
-pub fn log<T>(msg: T, level: LogState, state: LogState)
+pub fn log<T>(msg: T, state: LogState, level: LogLevel)
where
T: Display,
{
- if level == LogState::ERROR {
+ if state == LogState::ERROR {
log_error(msg);
- } else if level == LogState::WARNING {
- if state != LogState::ERROR {
+ } else if state == LogState::WARNING {
+ if level != LogLevel::ERROR {
log_warning(msg);
}
- } else if level == LogState::DEBUG {
- if state == LogState::DEBUG || state == LogState::VERBOSE {
+ } else if state == LogState::DEBUG {
+ if level == LogLevel::DEBUG || level == LogLevel::VERBOSE {
log_debug(msg);
}
- } else if level == LogState::VERBOSE {
- if state == LogState::VERBOSE {
+ } else if state == LogState::VERBOSE {
+ if level == LogLevel::VERBOSE {
log_verbose(msg);
}
} else {
#[structopt(
short = "l",
long = "log-level",
- possible_values = &debug_log::LogState::variants(),
+ possible_values = &debug_log::LogLevel::variants(),
default_value = "ERROR",
case_insensitive = true,
)]
- log_level: debug_log::LogState,
+ log_level: debug_log::LogLevel,
}
fn main() -> Result<(), String> {
-use crate::debug_log::{log, LogState};
+use crate::debug_log::{log, LogLevel, LogState};
use std::io::{self, Read, Write};
use std::net::{IpAddr, Ipv4Addr, SocketAddr, TcpStream};
use std::str::FromStr;
self_thread: Option<Arc<Mutex<thread::JoinHandle<Result<(), String>>>>>,
dirty_flag: Arc<AtomicBool>,
pub stop_flag: Arc<AtomicBool>,
- log_level: LogState,
+ log_level: LogLevel,
}
fn check_next_chars(
host: Ipv4Addr,
port: u16,
password: String,
- log_level: LogState,
+ log_level: LogLevel,
) -> Result<Self, String> {
let stream = TcpStream::connect_timeout(
&SocketAddr::new(IpAddr::V4(host), port),