upload.rs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. use clap::{App, Arg, SubCommand};
  2. use ffsend_api::action::params::{
  3. PARAMS_DEFAULT_DOWNLOAD_STR as DOWNLOAD_DEFAULT,
  4. };
  5. use cmd::arg::{ArgDownloadLimit, ArgHost, ArgPassword, CmdArg};
  6. /// The uplaod command definition.
  7. pub struct CmdUpload;
  8. impl CmdUpload {
  9. pub fn build<'a, 'b>() -> App<'a, 'b> {
  10. // Build the subcommand
  11. #[allow(unused_mut)]
  12. let mut cmd = SubCommand::with_name("upload")
  13. .about("Upload files.")
  14. .visible_alias("u")
  15. .visible_alias("up")
  16. .arg(Arg::with_name("FILE")
  17. .help("The file to upload")
  18. .required(true)
  19. .multiple(false))
  20. .arg(ArgPassword::build())
  21. .arg(ArgDownloadLimit::build().default_value(DOWNLOAD_DEFAULT))
  22. .arg(ArgHost::build())
  23. .arg(Arg::with_name("name")
  24. .long("name")
  25. .short("n")
  26. .alias("file")
  27. .alias("f")
  28. .value_name("NAME")
  29. .help("Rename the file being uploaded"))
  30. .arg(Arg::with_name("open")
  31. .long("open")
  32. .short("o")
  33. .help("Open the share link in your browser"));
  34. // Optional clipboard support
  35. #[cfg(feature = "clipboard")] {
  36. cmd = cmd.arg(Arg::with_name("copy")
  37. .long("copy")
  38. .short("c")
  39. .help("Copy the share link to your clipboard"));
  40. }
  41. cmd
  42. }
  43. }