fix parsing color

This commit is contained in:
race604 2022-07-19 17:10:47 +08:00
parent 1e5b5921c0
commit 23e6ab9ea8
2 changed files with 15 additions and 4 deletions

View file

@ -45,12 +45,23 @@ You can press `Space` key to _pause_ and _resume_ the timer.
## Run stopwatch
```shell
# Start timer for 5 minutes
$ tclock stopwatch
```
You can press `Space` key to _pause_ and _resume_ the stopwatch.
## Customize style
You can customize the styles.
* Size
You can use `-s` or `--size` option to custome clock size, for example:
```shell
$ tclock -s 2
```
# License
MIT License.

View file

@ -146,9 +146,9 @@ fn parse_color(s: &str) -> Result<Color, String> {
.captures(s)
.ok_or_else(|| format!("Invalid color: {}", s))?;
let hex = cap.get(1).unwrap().as_str();
let r = hex[1..3].parse::<u8>().unwrap();
let g = hex[3..5].parse::<u8>().unwrap();
let b = hex[5..7].parse::<u8>().unwrap();
let r = u8::from_str_radix(&hex[0..2], 16).unwrap();
let g = u8::from_str_radix(&hex[2..4], 16).unwrap();
let b = u8::from_str_radix(&hex[4..], 16).unwrap();
Ok(Color::Rgb(r, g, b))
}
}