Typical case:
class Controller:
db = {1: 'foo', 2: 'bar'}
def index(self):
return self.db.keys()
def detail(self, key):
return self.db[key]
c = Controller()
# now
parser.add_commands([c.index, c.detail])
# ideally
parser.add_controller(c)
parser.add_controller(c, namespace='my-controller')
# ideally — paranoid mode (requires an @expose decorator on methods)
parser.add_controller(c, only_exposed=True)
Modules can be added in the same way despite they are unlikely to be controllers:
# commands.py
def foo(): pass
def bar(): pass
# cli.py
import commands
parser.add_controller(commands)
# paranoid mode; really makes sense here
parser.add_controller(commands, only_exposed=True)
Note: This issue has been automatically migrated from Bitbucket
Created by @neithere on 2013-01-10 03:39:11+00:00, last updated: 2013-01-30 01:10:54+00:00
Typical case:
Modules can be added in the same way despite they are unlikely to be controllers:
Note: This issue has been automatically migrated from Bitbucket
Created by @neithere on 2013-01-10 03:39:11+00:00, last updated: 2013-01-30 01:10:54+00:00