Compare commits
No commits in common. "604f31d8e68f9c6ee3f9a286d0cf7e9074cd4f22" and "a40a493d39ffd7d1b092845758ed60cb03af1b06" have entirely different histories.
604f31d8e6
...
a40a493d39
1 changed files with 19 additions and 23 deletions
42
src/main.rs
42
src/main.rs
|
|
@ -60,26 +60,26 @@ fn parse_args(args: Vec<String>) -> Args {
|
||||||
}
|
}
|
||||||
|
|
||||||
if server.unwrap_or(false) {
|
if server.unwrap_or(false) {
|
||||||
if rest.is_empty() && sudo.is_none() {
|
if rest.len() == 0 && sudo.is_none() {
|
||||||
Args::Server
|
Args::Server
|
||||||
} else {
|
} else {
|
||||||
Args::Error
|
Args::Error
|
||||||
}
|
}
|
||||||
} else if rest.is_empty() {
|
} else if rest.len() >= 1 {
|
||||||
Args::Error
|
if rest[0] == "browse" {
|
||||||
} else if rest[0] == "browse" {
|
if rest.len() == 2 {
|
||||||
if rest.len() == 2 {
|
Args::Browse(rest[1].to_string())
|
||||||
Args::Browse(rest[1].to_string())
|
} else {
|
||||||
} else if rest.len() == 1 {
|
Args::Error
|
||||||
Args::Client(rest[0].to_string(), sudo.unwrap_or(false))
|
}
|
||||||
} else {
|
} else if rest[0] == "clip" {
|
||||||
Args::Error
|
if rest.len() == 1 {
|
||||||
}
|
Args::Clip(None)
|
||||||
} else if rest[0] == "clip" {
|
} else if rest.len() == 2 {
|
||||||
if rest.len() == 1 {
|
Args::Clip(Some(rest[1].to_string()))
|
||||||
Args::Clip(None)
|
} else {
|
||||||
} else if rest.len() == 2 {
|
Args::Error
|
||||||
Args::Clip(Some(rest[1].to_string()))
|
}
|
||||||
} else {
|
} else {
|
||||||
Args::Error
|
Args::Error
|
||||||
}
|
}
|
||||||
|
|
@ -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,7 +141,8 @@ mod tests {
|
||||||
|
|
||||||
// Goldarn it.
|
// Goldarn it.
|
||||||
fn args(x: &[&str]) -> Vec<String> {
|
fn args(x: &[&str]) -> Vec<String> {
|
||||||
let mut vec: Vec<String> = x.iter().map(|a| a.to_string()).collect();
|
let mut vec: Vec<String> =
|
||||||
|
x.into_iter().map(|a| a.to_string()).collect();
|
||||||
vec.insert(0, "fwd".to_string());
|
vec.insert(0, "fwd".to_string());
|
||||||
vec
|
vec
|
||||||
}
|
}
|
||||||
|
|
@ -187,11 +188,6 @@ mod tests {
|
||||||
assert_arg_parse!(&["--server"], Args::Server);
|
assert_arg_parse!(&["--server"], Args::Server);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn clip() {
|
|
||||||
assert_arg_parse!(&["clip"], Args::Clip(None));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn browse() {
|
fn browse() {
|
||||||
assert_arg_parse!(&["browse", "google.com"], Args::Browse(_));
|
assert_arg_parse!(&["browse", "google.com"], Args::Browse(_));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue