From 41657b7bb3a272c49dd8c8b44d03b58963c4906f Mon Sep 17 00:00:00 2001
From: "flyingscorpio@arch-desktop" <tfranken@protonmail.com>
Date: Sat, 5 Dec 2020 19:08:33 +0100
Subject: [PATCH] Add support for different config file

---
 install.py | 63 +++++++++++++++++++++++++++++++-----------------------
 1 file changed, 36 insertions(+), 27 deletions(-)

diff --git a/install.py b/install.py
index d3349d1..5595994 100755
--- a/install.py
+++ b/install.py
@@ -21,21 +21,22 @@ class Installer:
 
     def __init__(
         self,
-        force: bool = False,
+        config: str = "configs.yml",
         first_install: bool = False,
-        update: bool = False,
+        force: bool = False,
         hide_commands: bool = False,
+        update: bool = False,
     ):
         self.verify_secrets()
-        yaml = YAML(typ="safe")
-        self.conf = yaml.load(Path("configs.yml").text())
         self.base_dir = Path.getcwd()
-        self.home = Path("~").expanduser()
+        yaml = YAML(typ="safe")
+        self.conf = yaml.load(Path(config).text())
         self.force = force
         self.first_install = first_install
-        self.update = update
         self.hide_commands = hide_commands
+        self.home = Path("~").expanduser()
         self.operating_system = self.define_os()
+        self.update = update
 
     def verify_secrets(self) -> None:
         """The repository contains a secrets.template, that must be taken care of
@@ -454,16 +455,9 @@ def main() -> None:
         help="Programs to process, can be none",
     )
     parser.add_argument(
-        "-f",
-        "--from_file",
-        action="store_true",
-        help="Use 'process_list.txt' as programs to process",
-    )
-    parser.add_argument(
-        "-F",
-        "--force",
-        action="store_true",
-        help="Overwrite existing files",
+        "-c",
+        "--config",
+        help="Use CONFIG file (default: 'configs.yml')",
     )
     parser.add_argument(
         "-i",
@@ -471,12 +465,30 @@ def main() -> None:
         action="store_true",
         help="Assume the program is not installed",
     )
+    parser.add_argument(
+        "-F",
+        "--force",
+        action="store_true",
+        help="Overwrite existing files",
+    )
+    parser.add_argument(
+        "-f",
+        "--from_file",
+        action="store_true",
+        help="Use 'process_list.txt' as programs to process",
+    )
     parser.add_argument(
         "-g",
         "--generate",
         action="store_true",
         help="Generate a file containing all the programs from the config file",
     )
+    parser.add_argument(
+        "-H",
+        "--hide_commands",
+        action="store_true",
+        help="Hide command outputs",
+    )
     parser.add_argument(
         "-l",
         "--list_programs",
@@ -489,29 +501,26 @@ def main() -> None:
         action="store_true",
         help="Update programs",
     )
-    parser.add_argument(
-        "-H",
-        "--hide_commands",
-        action="store_true",
-        help="Hide command outputs",
-    )
 
     args = parser.parse_args()
 
     programs = args.programs
-    from_file = args.from_file
-    force = args.force
+
+    config = args.config
     first_install = args.first_install
+    force = args.force
+    from_file = args.from_file
     generate = args.generate
+    hide_commands = args.hide_commands
     list_programs = args.list_programs
     update = args.update
-    hide_commands = args.hide_commands
 
     installer = Installer(
-        force=force,
+        config=config,
         first_install=first_install,
-        update=update,
+        force=force,
         hide_commands=hide_commands,
+        update=update,
     )
 
     if generate: