Skip to content

Commit

Permalink
Merge pull request #13 from fabiobarkoski/cli
Browse files Browse the repository at this point in the history
UP CLI commands
  • Loading branch information
faermanj authored Dec 23, 2023
2 parents bae952a + 529b33c commit 91cb3af
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions upcli/up/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
from datetime import datetime
import shlex
import pkgutil

import uplib

Expand All @@ -9,19 +10,26 @@
def print_help():
log.debug("up [prompt]")

def get_modules():
up_plugins = []
for pkg in pkgutil.iter_modules():
if pkg.name.startswith("up_"):
up_plugins.append(pkg.name)
return up_plugins

def exit_cli(code=-1):
if code:
log.error("Exiting up cli with code %s", code)
if code == "NO_COMMAND_SPECIFIED":
log.error(f"installed plugins:\n{'\n'.join(get_modules())}")
sys.exit(code)


def cli_main():
now = datetime.now()
log.info(f"Starting UP cli at {now.isoformat()}")
args = sys.argv
len_args = len(args)
if len_args < 1:
if len_args <= 1:
print_help()
exit_cli("NO_COMMAND_SPECIFIED")
executable = args[0]
Expand Down

0 comments on commit 91cb3af

Please sign in to comment.