Skip to content

Commit

Permalink
fix(CLI): Added some CLI commands + docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tabbott36 committed Aug 22, 2024
1 parent 2c6d0c4 commit 9ed6779
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
4 changes: 4 additions & 0 deletions frbvoe/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -18,3 +20,5 @@ def version():


cli.add_command(voe)
cli.add_command(tns)
cli.add_command(subscriber)
9 changes: 6 additions & 3 deletions frbvoe/cli/subscriber.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Subscriber CLI."""

import click
from backend.subscriber import add_subscriber, delete_subscriber

@click.group(name="subscriber", help="Subscriber Tools.")

Expand All @@ -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.")
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.")
11 changes: 7 additions & 4 deletions frbvoe/cli/tns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
16 changes: 12 additions & 4 deletions frbvoe/cli/voe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

0 comments on commit 9ed6779

Please sign in to comment.