From 836494abc6b8e2be48dc8b1071ae19be125dce00 Mon Sep 17 00:00:00 2001 From: ejseqera Date: Tue, 9 Jan 2024 22:54:06 -0500 Subject: [PATCH] feat: update formatting and usability of CLI options --- seqerakit/__init__.py | 3 ++ seqerakit/cli.py | 69 +++++++++++++++++++++++++------------------ 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/seqerakit/__init__.py b/seqerakit/__init__.py index e69de29..fa5f80d 100644 --- a/seqerakit/__init__.py +++ b/seqerakit/__init__.py @@ -0,0 +1,3 @@ +import importlib.metadata as importlib_metadata + +__version__ = importlib_metadata.version(__name__) diff --git a/seqerakit/cli.py b/seqerakit/cli.py index 2872d4e..e6d09ef 100644 --- a/seqerakit/cli.py +++ b/seqerakit/cli.py @@ -31,69 +31,80 @@ def parse_args(args=None): - parser = argparse.ArgumentParser() - parser.add_argument( + parser = argparse.ArgumentParser( + description="Seqerakit: Python wrapper for the Seqera Platform CLI" + ) + + # General options + general = parser.add_argument_group("General Options") + general.add_argument( "-l", "--log_level", default="INFO", choices=("CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"), - help="The desired log level (default: INFO).", - type=str.upper, + help="Set the logging level.", ) - parser.add_argument( + general.add_argument( "--info", + "-i", action="store_true", - help="Display information about the Seqera Platform and exit", + help="Display Seqera Platform information and exit.", ) - parser.add_argument( + general.add_argument( "--dryrun", + "-d", action="store_true", - help="Print the commands that would be executed without running them.", + help="Print the commands that would be executed.", ) - parser.add_argument( + general.add_argument( + "--version", + "-v", + action="version", + version=f"%(prog)s {__version__}", + help="Show version number and exit.", + ) + + # YAML processing options + yaml_processing = parser.add_argument_group("YAML Processing Options") + yaml_processing.add_argument( "yaml", type=Path, - nargs="*", # allow multiple YAML paths - help="One or more YAML files with Seqera Platform resources to create", + nargs="*", + help="One or more YAML files with Seqera Platform resource definitions.", ) - parser.add_argument( + yaml_processing.add_argument( "--delete", action="store_true", - help="Recursively delete all resources defined in the YAML file(s)", + help="Recursively delete resources defined in the YAML files.", ) - parser.add_argument( + yaml_processing.add_argument( "--cli", dest="cli_args", type=str, help="Additional arguments to pass to Seqera Platform" " CLI enclosed in double quotes (e.g. '--cli=\"--insecure\"')", ) - parser.add_argument( - "dump", - help="Dump definitions for entities in the workspace to YAML file(s)", + + # YAML dumping options + yaml_dumping = parser.add_argument_group("YAML Dumping Options") + yaml_dumping.add_argument( + "--dump", help="Dump Seqera Platform entity definitions to YAML." ) - parser.add_argument( + yaml_dumping.add_argument( "--workspace", "-w", dest="workspace", type=str, - help="Name of the workspace to dump YAML definitions for", + help="Name/ID of the workspace to dump YAML definitions for", ) - parser.add_argument( + yaml_dumping.add_argument( "--prefix", "-p", dest="prefix", type=str, - help="Prefix to use for outputting YAML definition files (optional)\n" - "If not provided, the workspace name will be used as the prefix", - ) - parser.add_argument( - "--version", - "-v", - action="version", - version=f"%(prog)s v{__version__}", - help="Show the current version number and exit", + help="Prefix for output YAML files (defaults to workspace name).", ) + return parser.parse_args(args)