about summary refs log tree commit diff
path: root/scripts/cli
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-11-19 09:57:37 -0600
committerFrederick Muriuki Muriithi2025-11-19 13:34:31 -0600
commit960a816f69cb64b86d1a5ab2b3dddf9ef6c636fc (patch)
tree6e36258c740bab0d696d4e4e90f0a2049ac8d2da /scripts/cli
parentfead9b8054f483fa158ae75eb938462f2a844c0f (diff)
downloadgn-uploader-960a816f69cb64b86d1a5ab2b3dddf9ef6c636fc.tar.gz
Add utility functions for common CLI options/arguments.
Diffstat (limited to 'scripts/cli')
-rw-r--r--scripts/cli/options.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/cli/options.py b/scripts/cli/options.py
new file mode 100644
index 0000000..67f35dc
--- /dev/null
+++ b/scripts/cli/options.py
@@ -0,0 +1,46 @@
+"""General options to be added to CLI scripts."""
+from argparse import ArgumentParser
+
+
+def add_logging(parser: ArgumentParser) -> ArgumentParser:
+    """Add optional log-level option"""
+    loglevels = ("debug", "info", "warning", "error", "critical")
+    parser.add_argument(
+        "--log_level",
+        "--log-level",
+        "--loglevel",
+        metavar="LOG-LEVEL",
+        type=str,
+        default="INFO",
+        choices=loglevels,
+        help=(f"Controls the severity of events to log. Valid values are: " +
+              ", ".join(f"'{level}'" for level in loglevels)))
+    return parser
+
+
+def add_mariadb_uri(parser: ArgumentParser) -> ArgumentParser:
+    """Add the MySQL/MariaDB URI argument."""
+    parser.add_argument("db_uri",
+                        metavar="DB-URI",
+                        type=str,
+                        help="MariaDB/MySQL connection URL")
+    return parser
+
+
+def add_species_id(parser: ArgumentParser) -> ArgumentParser:
+    """Add species-id as a mandatory argument."""
+    parser.add_argument("species_id",
+                        metavar="SPECIES-ID",
+                        type=int,
+                        help="The species to operate on.")
+    return parser
+
+
+def add_population_id(parser: ArgumentParser) -> ArgumentParser:
+    """Add population-id as a mandatory argument."""
+    parser = add_species_id(parser)
+    parser.add_argument("population_id",
+                        metavar="POPULATION-ID",
+                        type=int,
+                        help="The ID for the population to operate on.")
+    return parser