Skip to content

Commit

Permalink
Add output option to commands
Browse files Browse the repository at this point in the history
  • Loading branch information
jonerickson committed Aug 13, 2023
1 parent bd88415 commit 2a94be8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions app/Commands/ResourceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ public function handle()
$keys = explode(',', $this->option('keys'));
}

render(view('api.view', [
'transformer' => $transformer->transform($response->json('data'), $keys),
]));
if ($this->option('output') === 'table') {
render(view('api.view', [
'transformer' => $transformer->transform($response->json('data'), $keys),
]));
} else {
$this->line($response);
}

return Command::SUCCESS;
}
Expand Down
3 changes: 2 additions & 1 deletion app/Commands/Users/UsersViewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class UsersViewCommand extends ResourceCommand
protected $signature = 'users:view
{--id= : The ID of a user (optional)}
{--keys= : A comma-delimited list of additional attributes to include (optional)}
{--include= : A comma-delimited list of resource relationships to include (optional)}';
{--include= : A comma-delimited list of resource relationships to include (optional)}
{--output=table : The intended output of the command (options: table, json)}';

/**
* The description of the command.
Expand Down

0 comments on commit 2a94be8

Please sign in to comment.