List commands should show a reduced set of columns

Change-Id: I8c56e5a9366e9e7b6569b7e001f069fc0a812470
This commit is contained in:
Kiall Mac Innes 2013-04-11 12:50:28 +01:00
parent 41fde43dab
commit 48bcdae017
4 changed files with 9 additions and 1 deletions

View File

@ -95,9 +95,11 @@ class Command(CliffCommand):
class ListCommand(Command, Lister):
columns = None
def post_execute(self, results):
if len(results) > 0:
columns = utils.get_columns(results)
columns = self.columns or utils.get_columns(results)
data = [utils.get_item_properties(i, columns) for i in results]
return columns, data
else:

View File

@ -23,6 +23,8 @@ LOG = logging.getLogger(__name__)
class ListDomainsCommand(base.ListCommand):
""" List Domains """
columns = ['id', 'name', 'serial']
def execute(self, parsed_args):
return self.client.domains.list()

View File

@ -23,6 +23,8 @@ LOG = logging.getLogger(__name__)
class ListRecordsCommand(base.ListCommand):
""" List Records """
columns = ['id', 'name']
def get_parser(self, prog_name):
parser = super(ListRecordsCommand, self).get_parser(prog_name)

View File

@ -23,6 +23,8 @@ LOG = logging.getLogger(__name__)
class ListServersCommand(base.ListCommand):
""" List Servers """
columns = ['id', 'name']
def execute(self, parsed_args):
return self.client.servers.list()