File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change 11import importlib
2+ import os
3+ import sys
24
35import click
46
@@ -28,21 +30,24 @@ def migration():
2830
2931
3032def main ():
31- cli ()
32-
33+ # In case it's run from an entrypoint:
34+ sys . path . insert ( 0 , os . getcwd ())
3335
34- if __name__ == "__main__" :
3536 try :
3637 import piccolo_conf
3738 except ImportError :
3839 print ("Can't import piccolo_conf - some commands may be missing." )
40+ else :
41+ COMMANDS = getattr (piccolo_conf , "COMMANDS" , [])
3942
40- COMMANDS = getattr (piccolo_conf , "COMMANDS" , [])
43+ for command in COMMANDS :
44+ command_name = command .split ("." )[- 1 ]
45+ command_module = importlib .import_module (command )
46+ command_func = getattr (command_module , "command" )
47+ cli .add_command (click .command (name = command_name )(command_func ))
48+
49+ cli ()
4150
42- for command in COMMANDS :
43- command_name = command .split ("." )[- 1 ]
44- command_module = importlib .import_module (command )
45- command_func = getattr (command_module , "command" )
46- cli .add_command (click .command (name = command_name )(command_func ))
4751
52+ if __name__ == "__main__" :
4853 main ()
You can’t perform that action at this time.
0 commit comments