]> git.nbdom.net Git - nb.git/commitdiff
CMD_ALIASE
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 29 Feb 2016 17:08:11 +0000 (17:08 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 29 Feb 2016 17:08:11 +0000 (17:08 +0000)
bin/dbq

diff --git a/bin/dbq b/bin/dbq
index 1b630a34f102c44e235273613c6b7101e2ab63a2..18203056b008cb7ee98af3e97077d294dc7b5d07 100755 (executable)
--- 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,$_);
   }