-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcli.py
More file actions
29 lines (21 loc) · 788 Bytes
/
Copy pathcli.py
File metadata and controls
29 lines (21 loc) · 788 Bytes
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
import os
import click
class ComplexCLI(click.MultiCommand):
def list_commands(self, ctx):
commands = []
commands_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), "commands"))
for filename in os.listdir(commands_folder):
if filename.endswith(".py") and filename.startswith("cmd_"):
commands.append(filename.replace("cmd_", "").replace(".py", ""))
commands.sort()
return commands
def get_command(self, ctx, name):
try:
mod = __import__(f"skyhawk.commands.cmd_{name}", None, None, ["cli"])
except ImportError:
return
return mod.cli
@click.command(cls=ComplexCLI)
def cli():
"""Welcome to Skyhawk! Auto-attandance cli tool"""
pass