From 32ebd18107ff93e95ecdb92f13bfa5ebe4d3ce45 Mon Sep 17 00:00:00 2001 From: Karolin Varner Date: Sun, 8 Dec 2024 01:17:13 +0100 Subject: [PATCH] chore(doc): Docu & tests for rosenpass/src/main.rs --- rosenpass/src/main.rs | 11 +++++++++++ rosenpass/tests/main-fn-prints-errors.rs | 10 ++++++++++ 2 files changed, 21 insertions(+) create mode 100644 rosenpass/tests/main-fn-prints-errors.rs diff --git a/rosenpass/src/main.rs b/rosenpass/src/main.rs index 93b41f5..42369c5 100644 --- a/rosenpass/src/main.rs +++ b/rosenpass/src/main.rs @@ -1,3 +1,5 @@ +//! For the main function + use clap::CommandFactory; use clap::Parser; use clap_mangen::roff::{roman, Roff}; @@ -5,6 +7,7 @@ use log::error; use rosenpass::cli::CliArgs; use std::process::exit; +/// Printing custom man sections when generating the man page fn print_custom_man_section(section: &str, text: &str, file: &mut std::fs::File) { let mut roff = Roff::default(); roff.control("SH", [section]); @@ -13,6 +16,8 @@ fn print_custom_man_section(section: &str, text: &str, file: &mut std::fs::File) } /// Catches errors, prints them through the logger, then exits +/// +/// The bulk of the command line logic is handled inside [crate::cli::CliArgs::run]. pub fn main() { // parse CLI arguments let args = CliArgs::parse(); @@ -81,21 +86,27 @@ pub fn main() { } } } + +/// Custom main page section: Exit Status static EXIT_STATUS_MAN: &str = r" The rosenpass utility exits 0 on success, and >0 if an error occurs."; +/// Custom main page section: See also. static SEE_ALSO_MAN: &str = r" rp(1), wg(1) Karolin Varner, Benjamin Lipp, Wanja Zaeske, and Lisa Schmidt, Rosenpass, https://rosenpass.eu/whitepaper.pdf, 2023."; +/// Custom main page section: Standards. static STANDARDS_MAN: &str = r" This tool is the reference implementation of the Rosenpass protocol, as specified within the whitepaper referenced above."; +/// Custom main page section: Authors. static AUTHORS_MAN: &str = r" Rosenpass was created by Karolin Varner, Benjamin Lipp, Wanja Zaeske, Marei Peischl, Stephan Ajuvo, and Lisa Schmidt."; +/// Custom main page section: Bugs. static BUGS_MAN: &str = r" The bugs are tracked at https://github.com/rosenpass/rosenpass/issues."; diff --git a/rosenpass/tests/main-fn-prints-errors.rs b/rosenpass/tests/main-fn-prints-errors.rs new file mode 100644 index 0000000..5b24871 --- /dev/null +++ b/rosenpass/tests/main-fn-prints-errors.rs @@ -0,0 +1,10 @@ +#[test] +fn main_fn_prints_errors() -> anyhow::Result<()> { + let out = test_bin::get_test_bin("rosenpass") + .args(["exchange-config", "/"]) + .output()?; + assert!(!out.status.success()); + assert!(String::from_utf8(out.stderr)?.contains("Is a directory (os error 21)")); + + Ok(()) +}