-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcli.py
More file actions
29 lines (24 loc) · 1.14 KB
/
cli.py
File metadata and controls
29 lines (24 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import sys
import argparse
from .generate import generate
from .function_cli import function_add_or_update
CLI_COMMANDS = ["generate", "function", "help"]
def execute_from_cli():
parser = argparse.ArgumentParser(
prog="python -m polyapi", description="PolyAPI Client"
)
parser.add_argument("--context", required=False, default="")
parser.add_argument("--description", required=False, default="")
parser.add_argument("--server", action="store_true", help="Pass --server if you want this to be a server function. By default, it will be a client function.")
parser.add_argument("--logs", action="store_true", help="Pass --logs if you want to store and see the logs from this function executing")
parser.add_argument("command", choices=CLI_COMMANDS)
parser.add_argument("subcommands", nargs="*")
args = parser.parse_args()
command = args.command
if command == "help":
parser.print_help()
elif command == "generate":
print("Generating...")
generate()
elif command == "function":
function_add_or_update(args.context, args.description, args.server, args.logs, args.subcommands)