A cli program to easily handle .gitignore files
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.0 KiB

  1. /*! Functions and templates which can be imported by app.rs to save effort */
  2. // Copyright 2017-2019, Stephan Sokolow
  3. // FIXME: Report that StructOpt is tripping Clippy's `result_unwrap_used` lint (which I use to push
  4. // for .expect() instead) in my two Option<T> fields and the `allow` gets ignored unless I
  5. // `#![...]` it onto the entire module.
  6. #![allow(clippy::result_unwrap_used)]
  7. use structopt::{clap, StructOpt};
  8. /// Modified version of Clap's default template for proper help2man compatibility
  9. ///
  10. /// Used as a workaround for:
  11. /// 1. Clap's default template interfering with `help2man`'s proper function
  12. /// ([clap-rs/clap/#1432](https://github.com/clap-rs/clap/issues/1432))
  13. /// 2. Workarounds involving injecting `\n` into the description breaking help output if used
  14. /// on subcommand descriptions.
  15. pub const HELP_TEMPLATE: &str = "{bin} {version}
  16. {about}
  17. USAGE:
  18. {usage}
  19. {all-args}
  20. ";
  21. /// Options used by boilerplate code
  22. // TODO: Move these into a struct of their own in something like helpers.rs
  23. #[derive(StructOpt, Debug)]
  24. #[structopt(rename_all = "kebab-case")]
  25. pub struct BoilerplateOpts {
  26. // -- Arguments used by main.rs --
  27. // TODO: Move these into a struct of their own in something like helpers.rs
  28. // FIXME: Report that StructOpt trips Clippy's `cast_possible_truncation` lint unless I use
  29. // `u64` for my `from_occurrences` inputs, which is a ridiculous state of things.
  30. /// Decrease verbosity (-q, -qq, -qqq, etc.)
  31. #[structopt(short, long, parse(from_occurrences))]
  32. pub quiet: u64,
  33. /// Increase verbosity (-v, -vv, -vvv, etc.)
  34. #[structopt(short, long, parse(from_occurrences))]
  35. pub verbose: u64,
  36. /// Display timestamps on log messages (sec, ms, ns, none)
  37. #[structopt(short, long, value_name = "resolution")]
  38. pub timestamp: Option<stderrlog::Timestamp>,
  39. /// Write a completion definition for the specified shell to stdout (bash, zsh, etc.)
  40. #[structopt(long, value_name = "shell")]
  41. pub dump_completions: Option<clap::Shell>,
  42. }