wip upload

This commit is contained in:
Quaternions 2023-12-30 17:31:11 -08:00
parent 927185ce64
commit 4f1065258e
2 changed files with 21 additions and 2 deletions

10
src/context.rs Normal file

@ -0,0 +1,10 @@
pub struct Context{
cookie:String,
}
impl Context{
pub fn new(cookie:String)->Self{
Self{
cookie,
}
}
}

@ -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(())
}