Add service and file arguments

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2021-12-27 01:11:44 +01:00
parent 41b272b704
commit bcd3861fe0
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -14,12 +14,14 @@ async fn main() -> Result<(), Option<()>> {
env_logger::init(); env_logger::init();
let args: Vec<String> = args().collect(); let args: Vec<String> = args().collect();
if args.len() != 3 { if args.len() != 5 {
println!("Usage: {} <jid> <password>", args[0]); println!("Usage: {} <jid> <password> <upload-service> <file>", args[0]);
return Err(None); return Err(None);
} }
let jid = &args[1]; let jid = &args[1];
let password = &args[2]; let password = &args[2];
let service = &args[3];
let file = Path::new(&args[4]);
// Client instance // Client instance
let mut client = ClientBuilder::new(jid, password) let mut client = ClientBuilder::new(jid, password)
@ -35,8 +37,8 @@ async fn main() -> Result<(), Option<()>> {
Event::Online => { Event::Online => {
println!("Online."); println!("Online.");
client.upload_file_with( client.upload_file_with(
"share.serv.ice" service,
Path::new("/some/file/path"), file,
).await; ).await;
} }
Event::HTTPUploadedFile(url) => { Event::HTTPUploadedFile(url) => {