This commit is contained in:
John Doty 2024-07-31 14:45:20 -07:00
parent a40a493d39
commit 3cb40bc2f4

View file

@ -60,12 +60,12 @@ fn parse_args(args: Vec<String>) -> Args {
} }
if server.unwrap_or(false) { if server.unwrap_or(false) {
if rest.len() == 0 && sudo.is_none() { if rest.is_empty() && sudo.is_none() {
Args::Server Args::Server
} else { } else {
Args::Error Args::Error
} }
} else if rest.len() >= 1 { } else if !rest.is_empty() {
if rest[0] == "browse" { if rest[0] == "browse" {
if rest.len() == 2 { if rest.len() == 2 {
Args::Browse(rest[1].to_string()) Args::Browse(rest[1].to_string())
@ -91,7 +91,7 @@ fn parse_args(args: Vec<String>) -> Args {
} }
async fn browse_url(url: &str) { async fn browse_url(url: &str) {
if let Err(e) = fwd::browse_url(&url).await { if let Err(e) = fwd::browse_url(url).await {
eprintln!("Unable to open {url}"); eprintln!("Unable to open {url}");
eprintln!("{}", e); eprintln!("{}", e);
std::process::exit(1); std::process::exit(1);
@ -141,8 +141,7 @@ mod tests {
// Goldarn it. // Goldarn it.
fn args(x: &[&str]) -> Vec<String> { fn args(x: &[&str]) -> Vec<String> {
let mut vec: Vec<String> = let mut vec: Vec<String> = x.iter().map(|a| a.to_string()).collect();
x.into_iter().map(|a| a.to_string()).collect();
vec.insert(0, "fwd".to_string()); vec.insert(0, "fwd".to_string());
vec vec
} }