Example #1
0
    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))
Example #2
0
    def __init__(self, prompt):
        Section.__init__(self, 'users', 'manages users in the system')
        self.prompt = prompt

        create_command = Command('create', 'creates a new user in the system', self.create)
        create_command.create_option('--username', 'username for the new user', required=True)
        create_command.create_option('--password', 'password for the new user', required=True)
        create_command.create_option('--group', 'group in which to assign the new user', required=False)

        self.add_command(create_command)
Example #3
0
    def __init__(self, prompt):
        Section.__init__(self, 'users', 'manages users in the system')
        self.prompt = prompt

        create_command = Command('create', 'creates a new user in the system', self.create)
        create_command.create_option('--username', 'username for the new user', required=True)
        create_command.create_option('--password', 'password for the new user', required=True)
        create_command.create_option('--group', 'group in which to assign the new user', required=False)

        self.add_command(create_command)
Example #4
0
    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))
Example #5
0
    def __init__(self, prompt):
        Section.__init__(self, 'demo1', 'demo section #1')
        self.prompt = prompt

        # Optional Argument Demo
        usage = 'Unspecified required arguments are listed at the bottom. The full ' \
                'listing of specified arguments is displayed when successfully run.'
        opt_arg_command = Command('opt-args', 'configured with multiple arguments, many optional',
                                  self.optional_args,
                                  usage_description=usage)
        opt_arg_command.create_option('--required-1',
                                      'required argument before this command will actually run',
                                      required=True)
        opt_arg_command.create_option('--optional-1',
                                      'optional argument, value will be displayed when specified',
                                      required=False)
        opt_arg_command.create_option('--optional-2', 'another optional argument', required=False)
        self.add_command(opt_arg_command)
Example #6
0
    def __init__(self, prompt):
        Section.__init__(self, 'demo1', 'demo section #1')
        self.prompt = prompt

        # Optional Argument Demo
        usage = 'Unspecified required arguments are listed at the bottom. The full ' \
                'listing of specified arguments is displayed when successfully run.'
        opt_arg_command = Command('opt-args', 'configured with multiple arguments, many optional',
                                  self.optional_args,
                                  usage_description=usage)
        opt_arg_command.create_option('--required-1',
                                      'required argument before this command will actually run',
                                      required=True)
        opt_arg_command.create_option('--optional-1',
                                      'optional argument, value will be displayed when specified',
                                      required=False)
        opt_arg_command.create_option('--optional-2', 'another optional argument', required=False)
        self.add_command(opt_arg_command)