You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
with the dynamic sub-commands located in the [root]/scripts/commands and dynamic loading in the main.py:
COMMANDS_FOLDER = os.path.join(os.path.dirname(__file__), 'scripts', 'commands')
class ApCli(click.MultiCommand):
def list_commands(self, ctx):
"""Provides names of all commands by searching the commands folder"""
rv = []
for filename in os.listdir(COMMANDS_FOLDER):
# find py files, ignore the ones that start with __ (f.e. __init__.py)
if filename.endswith('.py') and not filename.startswith('__'):
rv.append(filename[:-3])
rv.sort()
return rv
def get_command(self, ctx, name):
"""Returns compiled command for given name, expects that command has a function same as its name"""
ns = {}
fn = os.path.join(COMMANDS_FOLDER, name + '.py')
if os.path.isfile(fn):
with open(fn) as f:
code = compile(f.read(), fn, 'exec')
eval(code, ns, ns)
else:
return
if ns.get(name) is not None:
return ns[name]
@click.command(cls=ApCli)
@click.option('-v', '--verbose', is_flag=True, default=False, help='Enables verbose mode.')
@click.version_option()
@ap.pass_context
def cli(context, verbose):
"""Main entry point for the CLI"""
context.logger.isVerbose = verbose
However manual get generated only for our main entry point and for nothing else.. Any idea how can we fix this?
The text was updated successfully, but these errors were encountered:
Hi,
We use such setup:
with the dynamic sub-commands located in the [root]/scripts/commands and dynamic loading in the
main.py
:However manual get generated only for our main entry point and for nothing else.. Any idea how can we fix this?
The text was updated successfully, but these errors were encountered: