def __init__(self): Cli.__init__(self) self.username = None # CLI-level commands # Creating the Command instance directly: login_command = Command( 'login', 'persists user information across multiple calls', self.login) login_command.create_option('--username', 'identifies the user', ['-u'], required=True) self.add_command(login_command) # Using syntactic sugar methods: self.create_command('logout', 'removes (fake) stored credentials', self.logout) self.create_command('map', 'prints the map of all capabilities in the CLI', self.map) # Sections self.add_section(SampleSectionOne(self.prompt)) self.add_section(UsersSection(self.prompt))
def run(self, args): try: exit_code = Cli.run(self, args) return exit_code except Exception, e: code = self.context.exception_handler.handle_exception(e) return code
def __init__(self): Cli.__init__(self) self.username = None # CLI-level commands # Creating the Command instance directly: login_command = Command('login', 'persists user information across multiple calls', self.login) login_command.create_option('--username', 'identifies the user', ['-u'], required=True) self.add_command(login_command) # Using syntactic sugar methods: self.create_command('logout', 'removes (fake) stored credentials', self.logout) self.create_command('map', 'prints the map of all capabilities in the CLI', self.map) # Sections self.add_section(SampleSectionOne(self.prompt)) self.add_section(UsersSection(self.prompt))
def __init__(self, context): Cli.__init__(self, context.prompt) self.context = context