Closed Jaymon closed 4 years ago
inspired by fire
and function in the file would be a subcommand, so:
# script.py import captain def foo(): print("foo") def bar(): print("bar") captain.exit()
could be used like:
$ python script.py foo foo $ python script.py bar bar
classes could be sub-sub commands:
# script.py import captain def foo(): print("foo") class Bar(object): def che(self): print("bar che") def __call__(self): print ("bar") captain.exit()
would result in:
$ python script.py foo foo $ python script.py bar bar $python script.py bar che bar che
any function that started with an underscore (eg, def _baz) would be hidden from being called from the command line.
def _baz
The primary benefit would be getting rid of the main_ prefix. Though you could still use it if you had no subcommands, so:
main_
# script.py import captain def main(): print("main") captain.exit()
would be called with:
$ python script.py main
inspired by fire
and function in the file would be a subcommand, so:
could be used like:
classes could be sub-sub commands:
would result in:
any function that started with an underscore (eg,
def _baz
) would be hidden from being called from the command line.The primary benefit would be getting rid of the
main_
prefix. Though you could still use it if you had no subcommands, so:would be called with: