diff options
Diffstat (limited to 'testapi/testapi-client/testapiclient/cli/projects.py')
-rw-r--r-- | testapi/testapi-client/testapiclient/cli/projects.py | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/testapi/testapi-client/testapiclient/cli/projects.py b/testapi/testapi-client/testapiclient/cli/projects.py index 113b030..94a8fac 100644 --- a/testapi/testapi-client/testapiclient/cli/projects.py +++ b/testapi/testapi-client/testapiclient/cli/projects.py @@ -24,7 +24,16 @@ class ProjectGet(command.Lister): return parser def take_action(self, parsed_args): - self.show(client.get(self.filter_name(projects_url(), parsed_args))) + columns = ( + 'name', + '_id', + 'creator', + 'creation_date' + ) + data = client.get( + self.filter_by_name(projects_url(), + parsed_args)).get('projects', []) + return self.format_output(columns, data) class ProjectGetOne(command.ShowOne): @@ -38,10 +47,10 @@ class ProjectGetOne(command.ShowOne): return parser def take_action(self, parsed_args): - self.show(client.get(project_url(parsed_args))) + return self.format_output(client.get(project_url(parsed_args))) -class ProjectCreate(command.Command): +class ProjectCreate(command.ShowOne): def get_parser(self, prog_name): parser = super(ProjectCreate, self).get_parser(prog_name) @@ -54,8 +63,8 @@ class ProjectCreate(command.Command): @identity.authenticate def take_action(self, parsed_args): - self.show('Create', - client.post(projects_url(), parsed_args.project)) + return self.format_output( + client.post(projects_url(), parsed_args.project)) class ProjectDelete(command.Command): @@ -70,11 +79,10 @@ class ProjectDelete(command.Command): @identity.authenticate def take_action(self, parsed_args): - self.show('Delete', - client.delete(project_url(parsed_args))) + return client.delete(project_url(parsed_args)) -class ProjectPut(command.Command): +class ProjectPut(command.ShowOne): def get_parser(self, prog_name): parser = super(ProjectPut, self).get_parser(prog_name) @@ -91,5 +99,5 @@ class ProjectPut(command.Command): @identity.authenticate def take_action(self, parsed_args): - self.show('Update', - client.put(project_url(parsed_args), parsed_args.project)) + return self.format_output( + client.put(project_url(parsed_args), parsed_args.project)) |