From 8786a5e76d8db10acddc08bcb5b53e0b461d03b8 Mon Sep 17 00:00:00 2001 From: mirumi Date: Tue, 31 Oct 2023 10:50:03 +0900 Subject: [PATCH] Fix symbol name cannot include number digits --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/args.rs | 7 +++++-- src/guide.rs | 7 +++++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b4b5d23..feab0d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -984,7 +984,7 @@ dependencies = [ [[package]] name = "ro-soku" -version = "0.1.1" +version = "0.1.2" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 11d4e68..5ddad16 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ro-soku" -version = "0.1.1" +version = "0.1.2" authors = ["mirumi "] edition = "2021" description = "Retrieve OHLCV ro-soku (means a candle in Japanese) from any exchange🕯️" diff --git a/src/args.rs b/src/args.rs index 1b16931..fb9239f 100644 --- a/src/args.rs +++ b/src/args.rs @@ -156,8 +156,11 @@ impl Cli { fn check_symbol_format(&self) -> Result<(), Error> { ensure!( - self.symbol.chars().all(|c| c.is_uppercase() || c == '/') && self.symbol.contains('/'), - "Symbol pair must be in uppercase and contain `/`." + self.symbol + .chars() + .all(|c| c.is_uppercase() || c.is_ascii_digit() || c == '/') + && self.symbol.contains('/'), + "Symbol pair must be in uppercase or number and contain `/`." ); Ok(()) } diff --git a/src/guide.rs b/src/guide.rs index ea49d0c..4db18c9 100644 --- a/src/guide.rs +++ b/src/guide.rs @@ -164,8 +164,11 @@ impl Guide { .with_initial_text("BTC/USDT") .validate_with(|input: &String| { ensure!( - input.chars().all(|c| c.is_uppercase() || c == '/') && input.contains('/'), - "Symbol pair must be in uppercase and contain `/`." + input + .chars() + .all(|c| c.is_uppercase() || c.is_ascii_digit() || c == '/') + && input.contains('/'), + "Symbol pair must be in uppercase or number and contain `/`." ); Ok(()) })