diff options
| author | pi coding agent <pi@localhost> | 2026-10-22 18:59:33 +0000 |
|---|---|---|
| committer | Frederick Muriuki Muriithi <fredmanglis@gmail.com> | 2026-10-22 14:25:09 -0500 |
| commit | a897ceca02b78a9426652ac3092c79278cdc681c (patch) | |
| tree | 1ed499d3c583c93890d30864871740a276e4f718 /uploader/scripts/cli_parser.py | |
| parent | e3859b3945606aed7bd6a3861af8a525e061a2b1 (diff) | |
| download | gn-uploader-a897ceca02b78a9426652ac3092c79278cdc681c.tar.gz | |
Move scripts into the uploader package
Move the top-level `scripts` package to `uploader/scripts` so that it becomes the `uploader.scripts` package. All files are moved unchanged; references are updated in a follow-up commit.
Diffstat (limited to 'uploader/scripts/cli_parser.py')
| -rw-r--r-- | uploader/scripts/cli_parser.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/uploader/scripts/cli_parser.py b/uploader/scripts/cli_parser.py new file mode 100644 index 0000000..bf39731 --- /dev/null +++ b/uploader/scripts/cli_parser.py @@ -0,0 +1,47 @@ +"""Common utilities for CLI parsers""" +from uuid import UUID +from typing import Optional +from argparse import ArgumentParser + + +def add_logging_option(parser: ArgumentParser) -> ArgumentParser: + """Add optional log-level option""" + parser.add_argument( + "--log-level", + "--loglevel", + type=str, + default="INFO", + choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL", + "debug", "info", "warning", "error", "critical"], + help="The severity of events to track with the logger.") + return parser + + +def init_cli_parser(program: str, description: Optional[str] = None) -> ArgumentParser: + """Initialise the CLI arguments parser.""" + parser = ArgumentParser(prog=program, description=description) + + parser.add_argument( + "databaseuri", type=str, help="URI to connect to MariaDB") + parser.add_argument( + "redisuri", type=str, help="URI to connect to the redis server.") + parser.add_argument( + "redisprefix", type=str, help="A prefix to the job ID.") + parser.add_argument("jobid", type=UUID, help="Job ID that this belongs to") + parser.add_argument( + "--redisexpiry", + type=int, + default=86400, + help="How long to keep any redis keys around.") + return add_logging_option(parser) + + +def add_global_data_arguments(parser: ArgumentParser) -> ArgumentParser: + """Add the global (present in nearly ALL scripts) CLI arguments.""" + parser.add_argument("speciesid", + type=int, + help="Species to which bundle relates.") + parser.add_argument("populationid", + type=int, + help="Population to group data under") + return parser |
