Adds limit and start-table-name to table-list command

This commit is contained in:
Andrei V. Ostapenko 2014-05-16 13:19:41 +03:00
parent f2e48b23b5
commit b1eebe96e1
3 changed files with 22 additions and 5 deletions

View File

@ -590,9 +590,6 @@ class ShowCommand(MagnetoDBCommand, show.ShowOne):
add_show_list_common_argument(parser)
return parser
def _add_specific_args(parser):
pass
def format_output_data(self, resource):
for k, v in resource.iteritems():
if k in self._formatters:

View File

@ -47,6 +47,25 @@ class ListTable(magnetodbv1.ListCommand):
_formatters = {'Table Name': _format_table_name}
list_columns = ['Table Name']
def add_known_arguments(self, parser):
parser.add_argument(
'--limit',
type=int,
help=_('A maximum number of the items to return'))
parser.add_argument(
'--start-table-name',
help=_('The first table name that this operation will evaluate.'))
def args2search_opts(self, parsed_args):
search_opts = super(ListTable, self).args2search_opts(parsed_args)
limit = parsed_args.limit
start_table_name = parsed_args.start_table_name
if parsed_args.limit:
search_opts.update({'limit': limit})
if parsed_args.start_table_name:
search_opts.update({'start_table_name': start_table_name})
return search_opts
class ShowTable(magnetodbv1.ShowCommand):
"""Show information of a given table."""
@ -64,6 +83,7 @@ class ShowTable(magnetodbv1.ShowCommand):
'name', metavar='TABLE_NAME',
help=help_str)
class ListIndex(ShowTable):
"""List indices of a given table."""

View File

@ -144,9 +144,9 @@ class Client(object):
"""Delete the specified table."""
return self.delete(self.table_path % table_name)
def list_tables(self):
def list_tables(self, **params):
"""List tables."""
return self.get(self.tables_path)
return self.get(self.tables_path, params=params)
def describe_table(self, table_name):
"""Describe the specified table."""