From 9ed677984041b4e4816aaeb6729fc6a4331427a4 Mon Sep 17 00:00:00 2001 From: tabbott36 Date: Thu, 22 Aug 2024 16:59:02 -0400 Subject: [PATCH] fix(CLI): Added some CLI commands + docs --- frbvoe/cli/main.py | 4 ++++ frbvoe/cli/subscriber.py | 9 ++++++--- frbvoe/cli/tns.py | 11 +++++++---- frbvoe/cli/voe.py | 16 ++++++++++++---- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/frbvoe/cli/main.py b/frbvoe/cli/main.py index c0f09a0..e1c4c89 100644 --- a/frbvoe/cli/main.py +++ b/frbvoe/cli/main.py @@ -3,6 +3,8 @@ import click from frbvoe.cli.voe import voe +from frbvoe.cli.tns import tns +from frbvoe.cli.subscriber import subscriber @click.group() @@ -18,3 +20,5 @@ def version(): cli.add_command(voe) +cli.add_command(tns) +cli.add_command(subscriber) diff --git a/frbvoe/cli/subscriber.py b/frbvoe/cli/subscriber.py index b057430..a2e8173 100644 --- a/frbvoe/cli/subscriber.py +++ b/frbvoe/cli/subscriber.py @@ -1,6 +1,7 @@ """Subscriber CLI.""" import click +from backend.subscriber import add_subscriber, delete_subscriber @click.group(name="subscriber", help="Subscriber Tools.") @@ -14,8 +15,10 @@ def subscriber(): def add(subscriber_name, subscriber_email): """Add subscriber.""" + add_subscriber(subscriber_name, subscriber_email) click.echo(f"Saved subscriber {subscriber_name} with email {subscriber_email} to the database.") -def remove(subscriber_name, subscriber_email): - """Remove subscriber.""" - click.echo(f"Removed subscriber {subscriber_name} with email {subscriber_email} from the database.") \ No newline at end of file +def delete(subscriber_name, subscriber_email): + """Delete subscriber.""" + delete_subscriber(subscriber_name, subscriber_email) + click.echo(f"De subscriber {subscriber_name} with email {subscriber_email} from the database.") \ No newline at end of file diff --git a/frbvoe/cli/tns.py b/frbvoe/cli/tns.py index 61c5565..344e9fb 100644 --- a/frbvoe/cli/tns.py +++ b/frbvoe/cli/tns.py @@ -10,16 +10,19 @@ def tns(): """Manage workflow pipelines.""" pass - @tns.command("submit", help="Submit an FRB to the TNS.") @click.option( - "--period", default=10, help="Proprietary period of the FRB.", show_default=True -) + "--period", + default=10, + help="Proprietary period of the FRB.", + show_default=True + ) @click.option( "--sandbox", help="Submit to the sandbox TNS (if True) or live TNS (if False).", show_default=True, -) + ) + def submit(proprietary_period, sandbox): """Submit an FRB to the TNS.""" TNS.submit(proprietary_period, sandbox) diff --git a/frbvoe/cli/voe.py b/frbvoe/cli/voe.py index a6d26fb..18748ac 100644 --- a/frbvoe/cli/voe.py +++ b/frbvoe/cli/voe.py @@ -8,17 +8,25 @@ def voe(): """Manage workflow pipelines.""" pass - @voe.command("send", help="Send VOEvent.") -@click.option("--hostname", default="localhost", help="Destination to send the VOE.") -@click.option("--port", default=8098, help="Port to send the VOE.") +@click.option( + "--hostname", + default="localhost", + help="Destination to send the VOE." + ) +@click.option( + "--port", + default=8098, + help="Port to send the VOE." + ) @click.option( "--file", default="./voe", type=click.File("r"), help="VOEvent file.", show_default=True, -) + ) + def send(hostname, port): """Send VOEvent.""" click.echo(f"Send VOEvent.{hostname}:{port}")