diff --git a/src/context.rs b/src/context.rs new file mode 100644 index 0000000..19f6b36 --- /dev/null +++ b/src/context.rs @@ -0,0 +1,10 @@ +pub struct Context{ + cookie:String, +} +impl Context{ + pub fn new(cookie:String)->Self{ + Self{ + cookie, + } + } +} diff --git a/src/main.rs b/src/main.rs index 35d92c7..f544f04 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +pub mod context; + use std::io::{Read,Seek}; use clap::{Args,Parser,Subcommand}; use anyhow::Result as AResult; @@ -17,6 +19,7 @@ struct Cli{ enum Commands{ Download(AssetIDList), Upload{path:std::path::PathBuf,asset_id:u64}, + UploadToGroup{path:std::path::PathBuf,group_id:u64,asset_id:u64}, } #[derive(Args)] @@ -34,10 +37,16 @@ async fn main()->AResult<()>{ let cli=Cli::parse(); match cli.command{ Commands::Download(asset_id_list)=>download_list(asset_id_list.asset_ids).await, - Commands::Upload{path,asset_id}=>upload_file(path,asset_id), + Commands::Upload{path,asset_id}=>upload_file(path,Owner::User,asset_id), + Commands::UploadToGroup{path,group_id,asset_id}=>upload_file(path,Owner::Group(group_id),asset_id), } } +enum Owner{ + Group(u64), + User +} + enum ReaderType<'a,R:Read+Seek>{ GZip(flate2::read::GzDecoder<&'a mut R>), Raw(&'a mut R), @@ -55,7 +64,7 @@ fn maybe_gzip_decode<R:Read+Seek>(input:&mut R)->AResult<ReaderType<R>>{ } } -fn upload_file(path:std::path::PathBuf,asset_id:u64)->AResult<()>{ +fn upload_file(path:std::path::PathBuf,owner:Owner,asset_id:u64)->AResult<()>{ Ok(()) }