From fce417214db9becb706a73eea5eefecbccfe4238 Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 21 Jun 2024 03:18:21 +0900 Subject: [PATCH] WIP --- src/command/config/migrate/v20240701.rs | 4 ++-- src/config/server.rs | 3 ++- src/main.rs | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/command/config/migrate/v20240701.rs b/src/command/config/migrate/v20240701.rs index cb1b2ae..e536051 100644 --- a/src/command/config/migrate/v20240701.rs +++ b/src/command/config/migrate/v20240701.rs @@ -446,7 +446,7 @@ pub(super) async fn run() -> Result<(), Error> { .as_bytes(), ) .map_err(WriteTomlConfigError::ServerWrite)?; - cprintln!("config/server.toml has been created!"); + cprintln!("config/server.toml has been created!"); let mut client_toml = fs::File::create("config/client.toml").map_err(WriteTomlConfigError::ClientWrite)?; @@ -457,7 +457,7 @@ pub(super) async fn run() -> Result<(), Error> { .as_bytes(), ) .map_err(WriteTomlConfigError::ClientWrite)?; - cprintln!("config/client.toml has been created!"); + cprintln!("config/client.toml has been created!"); Ok(()) } diff --git a/src/config/server.rs b/src/config/server.rs index c0cc8f5..f6f1eca 100644 --- a/src/config/server.rs +++ b/src/config/server.rs @@ -6,7 +6,7 @@ // does not take care of it. use serde::{Deserialize, Serialize}; -use validator::{Validate, ValidationErrors}; +use validator::Validate; #[derive(Deserialize, Serialize, Validate, Debug)] pub struct Config { @@ -81,6 +81,7 @@ pub struct CacheServer { pub port: u16, pub user: Option, pub password: Option, + #[validate(range(min = 0, max = 15))] pub index: Option, pub prefix: Option, } diff --git a/src/main.rs b/src/main.rs index 150a143..b7979ee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ mod command; mod config; use clap::{Parser, Subcommand}; +use color_print::cprintln; /// latest Firefish version as of this fishctl release const FIREFISH_VERSION: &str = "20240613"; @@ -37,7 +38,7 @@ async fn main() { let res = run().await; if let Err(err) = res { - println!("An error occurred!"); + cprintln!("Error:"); println!(" raw: {:?}", err); println!(" message: {}", err);