Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added "moonstream" CLI with "create-query" command #724

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions clients/python/moonstream/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import argparse
import textwrap
import uuid

from .client import Moonstream


def handle_create_query(args: argparse.Namespace) -> None:
client = Moonstream()

query = ""
with args.query_file:
query = textwrap.indent(args.query_file.read(), " ")

client.create_query(args.token, query, args.name, args.public)


def main() -> None:
"""
Execute the Moonstream client command line.
"""
parser = argparse.ArgumentParser(
description="Command-line interface for the Moonstream Python client library. This CLI allows you to use client functionality from your command line."
)
subparsers = parser.add_subparsers(title="Commands")

create_query_parser = subparsers.add_parser("create-query")
create_query_parser.add_argument(
"-t",
"--token",
required=True,
type=uuid.UUID,
help="Access token for Moonstream API",
)
create_query_parser.add_argument(
"--query-file",
required=True,
type=argparse.FileType("r"),
help="File containing the query to add",
)
create_query_parser.add_argument(
"-n", "--name", required=True, help="Name for the new query"
)
create_query_parser.add_argument(
"--public",
action="store_true",
help="Set this flag if you want the query to be public",
)
create_query_parser.set_defaults(func=handle_create_query)

args = parser.parse_args()
args.func(args)


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion clients/python/moonstream/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MOONSTREAM_CLIENT_VERSION = "0.1.1"
MOONSTREAM_CLIENT_VERSION = "0.1.2"
1 change: 1 addition & 0 deletions clients/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@
"Topic :: Software Development :: Libraries",
],
url="https://github.com/bugout-dev/moonstream",
entry_points={"console_scripts": ["moonstream=moonstream.cli:main"]},
)