mirror of
https://github.com/house-of-vanity/rexec.git
synced 2025-07-07 00:54:06 +00:00
Fix some error handling
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1043,7 +1043,7 @@ checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
|
||||
|
||||
[[package]]
|
||||
name = "rexec"
|
||||
version = "1.0.2"
|
||||
version = "1.0.3"
|
||||
dependencies = [
|
||||
"brace-expand",
|
||||
"clap 4.3.4",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rexec"
|
||||
version = "1.0.3"
|
||||
version = "1.0.4"
|
||||
edition = "2021"
|
||||
description = "Parallel SSH executor"
|
||||
repository = "https://github.com/house-of-vanity/rexec"
|
||||
|
18
src/main.rs
18
src/main.rs
@ -91,8 +91,14 @@ fn expand_string(s: &str) -> Vec<Host> {
|
||||
|
||||
while let Some(r) = result.iter().find(|s| s.contains('[')) {
|
||||
let r = r.clone();
|
||||
let start = r.find('[').unwrap();
|
||||
let end = r.find(']').unwrap();
|
||||
let start = r.find(']').unwrap();
|
||||
let end = match r.find(']') {
|
||||
None => {
|
||||
error!("Error parsing host expression. Wrong range expansion '[a:b]'");
|
||||
process::exit(1);
|
||||
}
|
||||
Some(s) => s
|
||||
};
|
||||
let colon = r.find(':').unwrap();
|
||||
let low = r[start+1..colon].parse::<i32>().unwrap();
|
||||
let high = r[colon+1..end].parse::<i32>().unwrap();
|
||||
@ -106,7 +112,13 @@ fn expand_string(s: &str) -> Vec<Host> {
|
||||
while let Some(r) = result.iter().find(|s| s.contains('{')) {
|
||||
let r = r.clone();
|
||||
let start = r.find('{').unwrap();
|
||||
let end = r.find('}').unwrap();
|
||||
let end = match r.find('}') {
|
||||
None => {
|
||||
error!("Error parsing host expression. Wrong range expansion '{{one,two}}'");
|
||||
process::exit(1);
|
||||
}
|
||||
Some(s) => s
|
||||
};
|
||||
let list = &r[start+1..end];
|
||||
result.retain(|s| s != &r);
|
||||
for val in expand_list(list) {
|
||||
|
Reference in New Issue
Block a user