| 1 | package App::Ordo::Command::User::Show; | ||
| 2 | use Moo; | ||
| 3 | use feature qw(say); | ||
| 4 | extends 'App::Ordo::Command::Base'; | ||
| 5 | |||
| 6 | use Term::ANSIColor qw(colored); | ||
| 7 | use Text::Table::Tiny 1.02 qw(generate_table); | ||
| 8 | |||
| 9 | sub name { "user show" } | ||
| 10 | sub summary { "Show current user information and client version" } | ||
| 11 | sub usage { "" } | ||
| 12 | |||
| 13 | sub option_spec { {} } | ||
| 14 | |||
| 15 | sub execute { | ||
| 16 | my ($self) = @_; | ||
| 17 | |||
| 18 | # Get user info | ||
| 19 | my $user_res = $self->api->call('read_user', {}); | ||
| 20 | |||
| 21 | if ($user_res->{success}) { | ||
| 22 | say colored(["bold cyan"], "Current User\n"); | ||
| 23 | |||
| 24 | my $rows = [ | ||
| 25 | ["Key", "Value"], | ||
| 26 | ["ID", $user_res->{id} // '-'], | ||
| 27 | ["Email", $user_res->{email} // '-'], | ||
| 28 | ["Name", $user_res->{name} // '(none)'], | ||
| 29 | ["Level", $user_res->{level} // '-'], | ||
| 30 | ["Org ID", $user_res->{org_id} // '-'], | ||
| 31 | ["Current Path", $user_res->{path} // '-'], | ||
| 32 | ["Mode", $user_res->{mode} // '-'], | ||
| 33 | ["Remote Address", $user_res->{remote_address} // '-'], | ||
| 34 | ]; | ||
| 35 | |||
| 36 | say generate_table(rows => $rows, header_row => 1, style => 'boxrule'); | ||
| 37 | } else { | ||
| 38 | say colored(["bold red"], "Failed to retrieve user info"); | ||
| 39 | say $user_res->{message} if $user_res->{message}; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | 1; |