forked from StrafesNET/asset-tool
invalid states are representable but I don't care
This commit is contained in:
parent
aed3b69ca0
commit
589c1b044e
28
src/main.rs
28
src/main.rs
@ -37,7 +37,7 @@ struct Cli{
|
||||
cookie_file:Option<std::path::PathBuf>,
|
||||
|
||||
#[arg(long,value_parser=parse_key_val::<AssetID,std::path::PathBuf>)]
|
||||
asset_id:(AssetID,std::path::PathBuf),
|
||||
asset_id:Option<(AssetID,std::path::PathBuf)>,
|
||||
|
||||
#[arg(short,long)]
|
||||
input:Option<std::path::PathBuf>,
|
||||
@ -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()),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user