add default url

This commit is contained in:
Adam 2024-04-26 23:54:22 -04:00
parent 58cf288a90
commit bf88707844

View file

@ -25,7 +25,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// sleep to avoid racing the server on startup when using cargo watch // sleep to avoid racing the server on startup when using cargo watch
sleep(Duration::from_millis(200)).await; sleep(Duration::from_millis(200)).await;
if let Some(connect_addr) = env::args().nth(1) { let connect_addr = env::args()
.nth(1)
.unwrap_or_else(|| "ws://127.0.0.1:8080".to_string());
let url = url::Url::parse(&connect_addr)?; let url = url::Url::parse(&connect_addr)?;
let (stdin_tx, stdin_rx) = futures_channel::mpsc::unbounded(); let (stdin_tx, stdin_rx) = futures_channel::mpsc::unbounded();
@ -51,9 +53,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
pin_mut!(stdin_to_ws, ws_to_stdout); pin_mut!(stdin_to_ws, ws_to_stdout);
future::select(stdin_to_ws, ws_to_stdout).await; future::select(stdin_to_ws, ws_to_stdout).await;
} else {
eprintln!("This program requires at least one argument!")
}
Ok(()) Ok(())
} }