1#![warn(missing_docs)]
5
6pub mod prelude {
7 pub use crate as cli;
10 pub use ::clap;
11}
12
13pub fn get() -> Vec<String> {
19 #[cfg(target_arch = "wasm32")]
20 return {
21 let mut args = vec!["program".to_owned()]; let url = url::Url::parse(&web_sys::window().unwrap().location().href().unwrap())
23 .expect("Failed to parse window.location.href");
24 for (key, value) in url.query_pairs() {
25 let key: &str = &key;
26 let value: &str = &value;
27 if key == "args" {
28 args.push(value.to_owned());
29 } else if value.is_empty() {
30 args.push("--".to_owned() + key);
31 } else {
32 args.push("--".to_owned() + key + "=" + value);
33 }
34 }
35 log::trace!("href => args: {:?}", args);
36 args
37 };
38 #[cfg(not(target_arch = "wasm32"))]
39 return std::env::args().collect();
40}
41
42pub fn parse<T: clap::Parser>() -> T {
44 clap::Parser::parse_from(get())
45}