| 1 | use strict; | ||
| 2 | use warnings; | ||
| 3 | |||
| 4 | package Footprintless::Plugin::Database::Command::db::client; | ||
| 5 | $Footprintless::Plugin::Database::Command::db::client::VERSION = '1.06'; | ||
| 6 | # ABSTRACT: start a command line client | ||
| 7 | # PODNAME: Footprintless::Plugin::Database::Command::db::client | ||
| 8 | |||
| 9 | use parent qw(Footprintless::App::Action); | ||
| 10 | |||
| 11 | use Carp; | ||
| 12 | use Footprintless::App -ignore; | ||
| 13 | use Log::Any; | ||
| 14 | |||
| 15 | my $logger = Log::Any->get_logger(); | ||
| 16 | |||
| 17 | sub execute { | ||
| 18 | my ( $self, $opts, $args ) = @_; | ||
| 19 | |||
| 20 | $self->{db}->client( in_file => $self->{in_file}, client_options => $args ); | ||
| 21 | } | ||
| 22 | |||
| 23 | sub opt_spec { | ||
| 24 | return ( [ 'in-file=s', 'a sql script to pipe as input to the client' ] ); | ||
| 25 | } | ||
| 26 | |||
| 27 | sub usage_desc { | ||
| 28 | return 'fpl db DB_COORD client %o'; | ||
| 29 | } | ||
| 30 | |||
| 31 | sub validate_args { | ||
| 32 | my ( $self, $opts, $args ) = @_; | ||
| 33 | |||
| 34 | eval { $self->{db} = $self->{footprintless}->db( $self->{coordinate} ); }; | ||
| 35 | croak("invalid coordinate [$self->{coordinate}]: $@") if ($@); | ||
| 36 | |||
| 37 | if ( $opts->{in_file} ) { | ||
| 38 | my $command_helper = $self->{footprintless}->db_command_helper(); | ||
| 39 | $self->{in_file} = $command_helper->locate_file( $opts->{in_file} ); | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | 1; | ||
| 44 | |||
| 45 | __END__ |