Skip to content

Commit

Permalink
feat: add flag for emitting version info, refactor parseargs
Browse files Browse the repository at this point in the history
  • Loading branch information
ejseqera committed Mar 4, 2024
1 parent 843b011 commit f646f72
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 21 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ You will need to have an account on Seqera Platform (see [Plans and pricing](htt

`seqerakit` requires the following dependencies:

1. [Seqera Platform CLI](https://github.com/seqeralabs/tower-cli#1-installation)
1. [Seqera Platform CLI (`>=0.9.2`)](https://github.com/seqeralabs/tower-cli#1-installation)

2. [Python (`>=3.8`)](https://www.python.org/downloads/)

Expand Down Expand Up @@ -87,18 +87,22 @@ export TOWER_ACCESS_TOKEN=<your access token>

## Usage

To confirm the installation of `seqerakit`, configuration of the Seqera Platform CLI and connection is working as expected:
To confirm the installation of `seqerakit`, configuration of the Seqera Platform CLI and connection to the Platform is working as expected. This will run the `tw info` command under the hood:

```bash
seqerakit --info
```

Use the `-h` or `--help `parameter to list the available commands and their associated options:

Use the `--help` or `-h` parameter to list the available commands and their associated options:
```bash
seqerakit --help
```

Use `--version` or `-v` to retrieve the current version of your seqerakit installation:
```bash
seqerakit --version
```

### Dryrun

To print the commands that would executed with `tw` when using a YAML file, you can run `seqerakit` with the `--dryrun` flag:
Expand Down
3 changes: 3 additions & 0 deletions seqerakit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import importlib.metadata as importlib_metadata

__version__ = importlib_metadata.version(__name__)
49 changes: 32 additions & 17 deletions seqerakit/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,48 +24,63 @@
from pathlib import Path
from seqerakit import seqeraplatform, helper, overwrite
from seqerakit.seqeraplatform import ResourceExistsError, ResourceCreationError

from seqerakit import __version__

logger = logging.getLogger(__name__)


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\"')",
help="Additional Seqera Platform CLI specific options to be passed,"
" enclosed in double quotes (e.g. '--cli=\"--insecure\"').",
)
return parser.parse_args(args)

Expand Down

0 comments on commit f646f72

Please sign in to comment.