PageRenderTime 24ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/rust/aura/src/command/misc.rs

http://github.com/fosskers/aura
Rust | 36 lines | 21 code | 7 blank | 8 comment | 4 complexity | f2fcf7db2bccc63c2b359e17d63b4335 MD5 | raw file
Possible License(s): GPL-3.0, CC-BY-SA-4.0
  1. //! Miscellaneous functionality.
  2. use std::path::Path;
  3. /// Expected location of the `bat` executable if installed from official repos.
  4. const BAT: &str = "/bin/bat";
  5. /// Expected location of the `less` executable.
  6. const LESS: &str = "/bin/less";
  7. /// Expected location of the `ripgrep` executable.
  8. const RIPGREP: &str = "/bin/rg";
  9. /// Expected location of the `grep` executable.
  10. const GREP: &str = "/bin/grep";
  11. /// A complete path to a file viewer program like `less`.
  12. pub(crate) fn viewer() -> &'static str {
  13. let bat = Path::new(BAT);
  14. if bat.exists() {
  15. BAT
  16. } else {
  17. LESS
  18. }
  19. }
  20. /// A complete path to a file searcher program like `grep`, along with any extra
  21. /// arguments needed to affect the exact output.
  22. pub(crate) fn searcher() -> (&'static str, &'static [&'static str]) {
  23. let rg = Path::new(RIPGREP);
  24. if rg.exists() {
  25. (RIPGREP, &["-N"])
  26. } else {
  27. (GREP, &[])
  28. }
  29. }