From 63607e3d93ba7fedbaef7571e907b52dcf27331a Mon Sep 17 00:00:00 2001 From: Nick Chambers Date: Sun, 21 Aug 2022 18:34:49 -0500 Subject: [PATCH] Build the import list dynamically --- vultron/cmds/__init__.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/vultron/cmds/__init__.py b/vultron/cmds/__init__.py index 9c5fc98..9c820a6 100644 --- a/vultron/cmds/__init__.py +++ b/vultron/cmds/__init__.py @@ -1,4 +1,13 @@ -# FIXME: build this dynamically -__all__ = [ - "account", "application", "backup", "help", "region", "vpc" -] +import os +import pathlib + +# Not pretty but it works + +CMD_PATH = os.path.dirname(pathlib.Path(__file__).absolute()) +__all__ = [ ] + +for file in os.listdir(CMD_PATH): + path = os.path.join(CMD_PATH, file) + + if os.path.isfile(path) and file.endswith(".py") and file != "__init__.py": + __all__.append(file[:-3])