add bench helper
This commit is contained in:
parent
506e8850f8
commit
c8f6fa5aea
1 changed files with 40 additions and 0 deletions
40
frappe/utils/bench_helper.py
Normal file
40
frappe/utils/bench_helper.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import click
|
||||
import frappe
|
||||
import importlib
|
||||
|
||||
def main():
|
||||
click.Group(commands=get_app_groups())()
|
||||
|
||||
def get_cli_options():
|
||||
pass
|
||||
|
||||
def get_app_groups():
|
||||
ret = {}
|
||||
for app in get_apps():
|
||||
app_group = get_app_group(app)
|
||||
if app_group:
|
||||
ret[app] = app_group
|
||||
return ret
|
||||
|
||||
def get_app_group(app):
|
||||
app_commands = get_app_commands(app)
|
||||
if app_commands:
|
||||
return click.Group(name=app, commands=app_commands)
|
||||
|
||||
def get_app_commands(app):
|
||||
try:
|
||||
app_command_module = importlib.import_module(app + '.commands')
|
||||
except ImportError:
|
||||
return []
|
||||
|
||||
ret = {}
|
||||
for command in getattr(app_command_module, 'commands', []):
|
||||
ret[command.name] = command
|
||||
return ret
|
||||
|
||||
def get_apps():
|
||||
return frappe.get_all_apps(with_internal_apps=False, sites_path='.')
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Loading…
Add table
Reference in a new issue