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, name, description):
        Command.__init__(self, name, description, self.export)

        self.create_option('--server',
                           'Server to extract from',
                           aliases=['-s'],
                           required=False,
                           default=Config.values.server.url)
        self.create_option('--username',
                           'Username to access the server ',
                           aliases=['-u'],
                           required=False,
                           default=Config.values.server.username)
        self.create_option('--password',
                           'Password for the user',
                           aliases=['-p'],
                           required=False,
                           default=Config.values.server.password)
        self.create_option(
            '--directory',
            'Where to store output files. If not provided, go to std out',
            aliases=['-d'],
            required=False,
            default=Config.values.export.directory)
        self.create_option('--format',
                           'Output format (csv or json)',
                           aliases=['-f'],
                           required=False,
                           default=Config.values.export.outputformat)
        self.create_option('--org-mapping-file', 'file which provides a mpping between a satellite org id and an org name', \
            required=False, default=Config.values.mapping.orgs)
Example #3
0
    def __init__(self, name, description ):
        Command.__init__(self, name, description, self.export)

        self.create_option('--server', 'Server to extract from', aliases=['-s'], required=False, default=Config.values.server.url)
        self.create_option('--username', 'Username to access the server ', aliases=['-u'], required=False, default=Config.values.server.username)
        self.create_option('--password', 'Password for the user', aliases=['-p'], required=False, default=Config.values.server.password)
        self.create_option('--directory', 'Where to store output files. If not provided, go to std out', aliases=['-d'], required=False, default=Config.values.export.directory)
        self.create_option('--format', 'Output format (csv or json)', aliases=['-f'], required=False, default=Config.values.export.outputformat)
        self.create_option('--org-mapping-file', 'file which provides a mpping between a satellite org id and an org name', \
            required=False, default=Config.values.mapping.orgs)
Example #4
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 #5
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 #6
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 #7
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 #8
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 #9
0
 def __init__(self):
     Command.__init__(self, "dump_config", "print out the config file",
                      self.print_config)
Example #10
0
 def execute(self, prompt, args):
     self._load_saved_options()
     Command.execute(self, prompt, args)
Example #11
0
 def __init__(self):
     Command.__init__(self, "dump_config", "print out the config file", self.print_config)