mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
check if argument of initial-value is in the [0,100 range
This commit is contained in:
parent
1dc99e3a15
commit
ac39da6c97
1 changed files with 11 additions and 2 deletions
|
@ -137,8 +137,17 @@ fn setup(args: &[String]) -> Setup {
|
||||||
let initial_volume;
|
let initial_volume;
|
||||||
if matches.opt_present("initial-volume"){
|
if matches.opt_present("initial-volume"){
|
||||||
if matches.opt_str("initial-volume").unwrap().parse::<i32>().is_ok(){
|
if matches.opt_str("initial-volume").unwrap().parse::<i32>().is_ok(){
|
||||||
|
if matches.opt_str("initial-volume").unwrap().parse::<i32>().unwrap() < 0 {
|
||||||
|
initial_volume = 0 as i32;
|
||||||
|
}
|
||||||
|
else if matches.opt_str("initial-volume").unwrap().parse::<i32>().unwrap() > 100{
|
||||||
|
initial_volume = 0xFFFF as i32;
|
||||||
|
}
|
||||||
|
else{
|
||||||
initial_volume = matches.opt_str("initial-volume").unwrap().parse::<i32>().unwrap()* 0xFFFF as i32 / 100 ;
|
initial_volume = matches.opt_str("initial-volume").unwrap().parse::<i32>().unwrap()* 0xFFFF as i32 / 100 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
initial_volume = 0x8000 as i32;
|
initial_volume = 0x8000 as i32;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue