#![warn(missing_docs)]
pub mod prelude {
pub use crate as cli;
pub use ::clap;
}
pub fn get() -> Vec<String> {
#[cfg(target_arch = "wasm32")]
return {
let mut args = vec!["program".to_owned()]; let url = url::Url::parse(&web_sys::window().unwrap().location().href().unwrap())
.expect("Failed to parse window.location.href");
for (key, value) in url.query_pairs() {
let key: &str = &key;
let value: &str = &value;
if key == "args" {
args.push(value.to_owned());
} else if value.is_empty() {
args.push("--".to_owned() + key);
} else {
args.push("--".to_owned() + key + "=" + value);
}
}
log::trace!("href => args: {:?}", args);
args
};
#[cfg(not(target_arch = "wasm32"))]
return std::env::args().collect();
}
pub fn parse<T: clap::Parser>() -> T {
clap::Parser::parse_from(get())
}