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.

68 lines
2.3KB

  1. /*
  2. * meli - build.rs
  3. *
  4. * Copyright 2020 Manos Pitsidianakis
  5. *
  6. * This file is part of meli.
  7. *
  8. * meli is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * meli is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with meli. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. fn main() {
  22. #[cfg(feature = "cli-docs")]
  23. {
  24. const MANDOC_OPTS: &[&'static str] = &["-T", "utf8", "-I", "os=Generated by mandoc(1)"];
  25. use std::env;
  26. use std::fs::File;
  27. use std::io::prelude::*;
  28. use std::path::Path;
  29. use std::process::Command;
  30. let out_dir = env::var("OUT_DIR").unwrap();
  31. let mut out_dir_path = Path::new(&out_dir).to_path_buf();
  32. out_dir_path.push("meli.txt");
  33. let output = Command::new("mandoc")
  34. .args(MANDOC_OPTS)
  35. .arg("meli.1")
  36. .output()
  37. .or_else(|_| Command::new("man").arg("-l").arg("meli.1").output())
  38. .unwrap();
  39. let mut file = File::create(&out_dir_path).unwrap();
  40. file.write_all(&output.stdout).unwrap();
  41. out_dir_path.pop();
  42. out_dir_path.push("meli.conf.txt");
  43. let output = Command::new("mandoc")
  44. .args(MANDOC_OPTS)
  45. .arg("meli.conf.5")
  46. .output()
  47. .or_else(|_| Command::new("man").arg("-l").arg("meli.conf.5").output())
  48. .unwrap();
  49. let mut file = File::create(&out_dir_path).unwrap();
  50. file.write_all(&output.stdout).unwrap();
  51. out_dir_path.pop();
  52. out_dir_path.push("meli-themes.txt");
  53. let output = Command::new("mandoc")
  54. .args(MANDOC_OPTS)
  55. .arg("meli-themes.5")
  56. .output()
  57. .or_else(|_| Command::new("man").arg("-l").arg("meli-themes.5").output())
  58. .unwrap();
  59. let mut file = File::create(&out_dir_path).unwrap();
  60. file.write_all(&output.stdout).unwrap();
  61. }
  62. }