diff --git a/src/main.rs b/src/main.rs index 0ed9e3b..ec0a258 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,7 +37,7 @@ struct Cli{ cookie_file:Option, #[arg(long,value_parser=parse_key_val::)] - asset_id:(AssetID,std::path::PathBuf), + asset_id:Option<(AssetID,std::path::PathBuf)>, #[arg(short,long)] input:Option, @@ -68,21 +68,25 @@ async fn main()->AResult<()>{ let cookie_enum={ match (cli.cookie_literal,cli.cookie_env,cli.cookie_file){ - (Some(literal),None,None)=>Cookie::Literal(literal), - (None,Some(env_var),None)=>Cookie::Environment(env_var), - (None,None,Some(path))=>Cookie::File(path), - _=>return Err(anyhow::Error::msg("Cookie was not specified or was specified multiple times.")), + (Some(literal),None,None)=>Some(Cookie::Literal(literal)), + (None,Some(env_var),None)=>Some(Cookie::Environment(env_var)), + (None,None,Some(path))=>Some(Cookie::File(path)), + (None,None,None)=>None, + _=>return Err(anyhow::Error::msg("Cookie was specified multiple times.")), } }; - let cookie=format!(".ROBLOSECURITY={}",match cookie_enum{ - Cookie::Literal(s)=>s, - Cookie::Environment(var)=>std::env::var(var)?, - Cookie::File(path)=>tokio::fs::read_to_string(path).await?, - }); + let cookie=match cookie_enum{ + Some(c)=>Some(format!(".ROBLOSECURITY={}",match c{ + Cookie::Literal(s)=>s, + Cookie::Environment(var)=>std::env::var(var)?, + Cookie::File(path)=>tokio::fs::read_to_string(path).await?, + })), + None=>None, + }; match cli.command{ - Commands::Download=>download_list(cookie,vec![cli.asset_id]).await, - Commands::Upload=>upload_list(cookie,cli.group,vec![cli.asset_id]).await, + 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::Compile=>compile(cli.input.unwrap(),cli.output.unwrap()), Commands::Decompile=>decompile(cli.input.unwrap(),cli.output.unwrap()), }