wip upload
This commit is contained in:
parent
927185ce64
commit
4f1065258e
10
src/context.rs
Normal file
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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
src/main.rs
13
src/main.rs
@ -1,3 +1,5 @@
|
|||||||
|
pub mod context;
|
||||||
|
|
||||||
use std::io::{Read,Seek};
|
use std::io::{Read,Seek};
|
||||||
use clap::{Args,Parser,Subcommand};
|
use clap::{Args,Parser,Subcommand};
|
||||||
use anyhow::Result as AResult;
|
use anyhow::Result as AResult;
|
||||||
@ -17,6 +19,7 @@ struct Cli{
|
|||||||
enum Commands{
|
enum Commands{
|
||||||
Download(AssetIDList),
|
Download(AssetIDList),
|
||||||
Upload{path:std::path::PathBuf,asset_id:u64},
|
Upload{path:std::path::PathBuf,asset_id:u64},
|
||||||
|
UploadToGroup{path:std::path::PathBuf,group_id:u64,asset_id:u64},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
@ -34,10 +37,16 @@ async fn main()->AResult<()>{
|
|||||||
let cli=Cli::parse();
|
let cli=Cli::parse();
|
||||||
match cli.command{
|
match cli.command{
|
||||||
Commands::Download(asset_id_list)=>download_list(asset_id_list.asset_ids).await,
|
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>{
|
enum ReaderType<'a,R:Read+Seek>{
|
||||||
GZip(flate2::read::GzDecoder<&'a mut R>),
|
GZip(flate2::read::GzDecoder<&'a mut R>),
|
||||||
Raw(&'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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user