upload.rs 2.1 KB

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