diff --git a/src/main.rs b/src/main.rs index 148fbbd..9ba9453 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,20 +8,6 @@ type AssetID=u64; type AssetIDFileMap=Vec<(AssetID,std::path::PathBuf)>; const CONCURRENT_REQUESTS:usize=8; -/// Parse a single key-value pair -fn parse_key_val(s:&str)->AResult<(T,U)> -where - T:std::str::FromStr, - T::Err:std::error::Error+Send+Sync+'static, - U:std::str::FromStr, - U::Err:std::error::Error+Send+Sync+'static, -{ - let pos=s - .find('=') - .ok_or_else(||anyhow::Error::msg(format!("invalid KEY=value: no `=` found in `{s}`")))?; - Ok((s[..pos].parse()?,s[pos+1..].parse()?)) -} - #[derive(Parser)] #[command(author,version,about,long_about=None)] #[command(propagate_version = true)] @@ -36,8 +22,8 @@ struct Cli{ #[arg(long)] cookie_file:Option, - #[arg(long,value_parser=parse_key_val::)] - asset_id:Option<(AssetID,std::path::PathBuf)>, + #[arg(long)] + asset_id:Option, #[arg(short,long)] input:Option, @@ -85,8 +71,8 @@ async fn main()->AResult<()>{ }; match cli.command{ - Commands::Download=>download_list(cookie.unwrap(),vec![cli.asset_id.unwrap()]).await, - Commands::Upload=>upload_list(cookie.unwrap(),cli.group,vec![cli.asset_id.unwrap()]).await, + Commands::Download=>download_list(cookie.unwrap(),vec![(cli.asset_id.unwrap(),cli.output.unwrap())]).await, + Commands::Upload=>upload_list(cookie.unwrap(),cli.group,vec![(cli.asset_id.unwrap(),cli.output.unwrap())]).await, Commands::Compile=>compile(cli.input.unwrap(),cli.output.unwrap()), Commands::Decompile=>decompile(cli.input.unwrap(),cli.output.unwrap()), }