about summary refs log tree commit diff
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2024-03-03 19:14:26 +0100
committerProfpatsch <mail@profpatsch.de>2024-03-03 19:14:26 +0100
commit78aef4a0065e1238a1f209e7446867fd8cd7af82 (patch)
tree522f6598230862e62d8b606347f5265cd9889b62
parenta4babce7ff635d46cadb758c66dccb93e8dd6daa (diff)
pkgs/profpatsch/nman: start returning more info from build
-rw-r--r--pkgs/profpatsch/nman/nman.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/pkgs/profpatsch/nman/nman.rs b/pkgs/profpatsch/nman/nman.rs
index 9f057acf..96ec3e59 100644
--- a/pkgs/profpatsch/nman/nman.rs
+++ b/pkgs/profpatsch/nman/nman.rs
@@ -261,6 +261,12 @@ struct Main {
     is_debug: bool,
 }
 
+enum OutputDirResult {
+    NoManDir,
+    NoManPageFound,
+    FoundManPage(PathBuf),
+}
+
 impl Main {
     /// This function implements the main operation of `nman`:
     /// It instantiates the given attribute to get all outputs
@@ -340,7 +346,7 @@ impl Main {
             let man_file = self.build_man_page(&drv, section, page, &tmpdir)?;
 
             match man_file {
-                None => {
+                OutputDirResult::NoManDir | OutputDirResult::NoManPageFound => {
                     self.debug_log(format!(
                         r#"no manpage for {} found in output "{}""#,
                         manpage_display,
@@ -348,7 +354,7 @@ impl Main {
                     ));
                     continue;
                 }
-                Some(file) => {
+                OutputDirResult::FoundManPage(file) => {
                     self.debug_log(format!(
                         r#"found manpage {} in output "{}", opening …"#,
                         manpage_display,
@@ -388,7 +394,7 @@ impl Main {
         section: Option<&str>,
         page: &str,
         tempdir: &TempDir,
-    ) -> Result<Option<PathBuf>, NmanError<'a>> {
+    ) -> Result<OutputDirResult, NmanError<'a>> {
         let build = self
             .debug_log_command(
                 Command::new("nix-store")
@@ -420,7 +426,7 @@ impl Main {
 
         // no share/man, no man pages
         if !path.exists() {
-            return Ok(None);
+            return Ok(OutputDirResult::NoManDir);
         }
 
         // expected sub directory of share/man or, if no section
@@ -468,7 +474,7 @@ impl Main {
                             .map(|f| match_man_page_file(f, s, page));
 
                         if mmatch.unwrap_or(false) {
-                            return Ok(Some(file.path()));
+                            return Ok(OutputDirResult::FoundManPage(file.path()));
                         }
                     }
                 }
@@ -476,7 +482,7 @@ impl Main {
             }
         }
 
-        Ok(None)
+        Ok(OutputDirResult::NoManPageFound)
     }
 
     fn debug_log<S>(&self, msg: S)