From 6dfcee04ad277df02a7f317535b5954dad3069ec Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Wed, 7 Feb 2024 19:44:05 -0700
Subject: [PATCH] Add output-config parameter to installer for getting merged
 config

---
 src/bin/installer.rs | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/bin/installer.rs b/src/bin/installer.rs
index c04d7cc..19adcd3 100644
--- a/src/bin/installer.rs
+++ b/src/bin/installer.rs
@@ -18,6 +18,7 @@ fn main() {
     let mut parser = ArgParser::new(4)
         .add_opt("b", "cookbook")
         .add_opt("c", "config")
+        .add_opt("o", "output-config")
         .add_flag(&["filesystem-size"])
         .add_flag(&["r", "repo-binary"])
         .add_flag(&["l", "list-packages"])
@@ -40,10 +41,19 @@ fn main() {
         redox_installer::Config::default()
     };
 
+    // Get toml of merged config
+    let merged_toml = toml::to_string_pretty(&config).unwrap();
+
+    // Just output merged config and exit
+    if let Some(path) = parser.get_opt("output-config") {
+        fs::write(path, merged_toml).unwrap();
+        return;
+    }
+
     // Add filesystem.toml to config
     config.files.push(redox_installer::FileConfig {
         path: "filesystem.toml".to_string(),
-        data: toml::to_string_pretty(&config).unwrap(),
+        data: merged_toml,
         ..Default::default()
     });
 
-- 
GitLab