From: Nicolas Boisselier Date: Mon, 29 Feb 2016 17:08:11 +0000 (+0000) Subject: CMD_ALIASE X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=aea2b28c6ede7a58fef9122cf1b2e762c5d329f6;p=nb.git CMD_ALIASE --- diff --git a/bin/dbq b/bin/dbq index 1b630a34..18203056 100755 --- a/bin/dbq +++ b/bin/dbq @@ -23,6 +23,18 @@ my %ACTION = ( 'format' => $ENV{$UC_NAME.'_FORMAT'} ? $ENV{$UC_NAME.'_FORMAT'} : 'json', 'action' => $ENV{$UC_NAME.'_ACTION'} ? $ENV{$UC_NAME.'_ACTION'} : 'rows', ); +my @CURL_OPT = ( + 'dump-header|D=s', + 'get|G!', +); + +my %CMD_ALIASE = ( + 'f' => 'format', + 't' => 'table', + 'a' => 'action', + 'l' => 'limit', +); + ################################################################################# # @@ -35,15 +47,10 @@ my $DEBUG = $main::DEBUG = 0; csv2txt("\t",shift @ARGV) if @ARGV and $ARGV[0] eq '--csv2txt' and shift @ARGV; curl_help() if @ARGV and $ARGV[0] eq '--curl_help' and shift @ARGV; -my @curl_opt = ( - 'dump-header|D=s', - 'get|G!', -); - -my %Opt; get_options(\%Opt,\@curl_opt); +my %Opt; get_options(\%Opt,\@CURL_OPT); #use Data::Dumper; die Dumper(\%Opt); -for (@curl_opt) { +for (@CURL_OPT) { s/\|.*$//; next unless $Opt{$_}; if ($Opt{$_} ne '1') { @@ -71,7 +78,7 @@ my %keys = (); while ($_ = shift @ARGV) { if (/^([^=]+)=(.*)$/) { - $keys{$1} = $2; + $keys{($CMD_ALIASE{$1} ? $CMD_ALIASE{$1} : $1)} = $2; } else { push(@cmd,$_); }