Commit 371ad375 authored by Grant's avatar Grant
Browse files

add cli entrypoint

parent 2829e190
Loading
Loading
Loading
Loading
+102 −276

File changed.

Preview size limit exceeded, changes collapsed.

+31 −0
Original line number Diff line number Diff line
"""Initialize the CLI module."""
import os
import subprocess

try:
    import click
except ImportError:
    import sys

    from common.logz import create_logger

    logger = create_logger()
    logger.warn("the [cli] extra must be installed. ")
    sys.exit(1)


@click.group()
def of_cli():
    """Common/OnlyFeatures CLI."""
    pass


# noqa: PEP402
from common.cli.docker_cli import docker


of_cli.add_command(docker)


if __name__ == "__main__":
    of_cli()
+25 −0
Original line number Diff line number Diff line
"""Command line arguments for helping with docker."""
import os
import subprocess

import click


@click.group()
def docker():
    """Docker related commands."""
    pass


@docker.command(name='remove-volumes',
                help='Remove all docker volumes with a specific prefix.')
@click.argument('prefix', required=False)
def remove_volumes(prefix):
    """Remove all docker volumes with a specific prefix."""
    if not prefix:
        prefix = os.path.basename(os.getcwd())
    command = f"docker volume ls -q --filter name={prefix} | xargs -r docker volume rm"
    subprocess.run(command, shell=True)


docker.add_command(docker)
 No newline at end of file
+10 −2
Original line number Diff line number Diff line
@@ -55,6 +55,10 @@ scrapers = [
    "beautifulsoup4~=4.10.0",
    "websocket~=0.2.1"
]
cli = [
    "rich==13.7.1",
    "click==8.0.3"
]
all = [
    "psycopg2-binary==2.9.9",
    "pymssql==2.2.11",
@@ -67,7 +71,9 @@ all = [
    "beautifulsoup4~=4.10.0",
    "websocket~=0.2.1",
    "ldap3==2.9.1",
    "flask>=2.0.2"
    "flask>=2.0.2",
    "rich==13.7.1",
    "click==8.0.3"
]


@@ -76,5 +82,7 @@ Source = "https://code.ornl.gov/nset-utilities/common-package"


[tool.setuptools]
packages = ['common', 'common.mixins', 'common.scrapers']
packages = ['common', 'common.mixins', 'common.scrapers', 'common.cli']

[project.scripts]
of = "common.cli:of_cli"