use output instead of key val pair
This commit is contained in:
parent
bb32d30896
commit
5f1178d0cf
22
src/main.rs
22
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<T,U>(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<std::path::PathBuf>,
|
||||
|
||||
#[arg(long,value_parser=parse_key_val::<AssetID,std::path::PathBuf>)]
|
||||
asset_id:Option<(AssetID,std::path::PathBuf)>,
|
||||
#[arg(long)]
|
||||
asset_id:Option<AssetID>,
|
||||
|
||||
#[arg(short,long)]
|
||||
input:Option<std::path::PathBuf>,
|
||||
@ -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()),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user