Add aliases for actions

--foo is now equivalent of --action=foo
tags/patrix-0.1.4-1
Daniel Berteaud 7 years ago
parent b19a7edc9a
commit ffac9f3632
  1. 58
      scripts/patrix

@ -19,26 +19,35 @@ use Scalar::Util qw(looks_like_number);
our $opt; our $opt;
GetOptions( GetOptions(
"user=s" => \$opt->{user}, "user=s" => \$opt->{user},
"password=s" => \$opt->{password}, "password=s" => \$opt->{password},
"access_token=s" => \$opt->{access_token}, "access_token=s" => \$opt->{access_token},
"server=s" => \$opt->{server}, "server=s" => \$opt->{server},
"room=s" => \$opt->{room}, "room=s" => \$opt->{room},
"message=s" => \$opt->{message}, "message=s" => \$opt->{message},
"files=s" => \$opt->{file}, "files=s" => \$opt->{file},
"debug" => \$opt->{debug}, "debug" => \$opt->{debug},
"action=s" => \$opt->{action}, "action=s" => \$opt->{action},
"conf=s" => \$opt->{conf}, "send-msg" => \$opt->{'send-msg'},
"invite=s@" => \$opt->{invite}, "send-notice" => \$opt->{'send-notice'},
"name=s" => \$opt->{name}, "send-file" => \$opt->{'send-file'},
"alias=s" => \$opt->{alias}, "create-room" => \$opt->{'create-room'},
"topic=s" => \$opt->{topic}, "modify-room" => \$opt->{'modify-room'},
"join_rules=s" => \$opt->{join_rules}, "delete-room-alias" => \$opt->{'delete-room-alias'},
"federation!" => \$opt->{federation}, "get-access-token" => \$opt->{'get-access-token'},
"perm=s@" => \$opt->{perm}, "get-room-list" => \$opt->{'get-room-list'},
"perm_user=s@" => \$opt->{perm_user}, "get-room-id" => \$opt->{'get-room-id'},
"perm_event=s@" => \$opt->{perm_user}, "conf=s" => \$opt->{conf},
"perm_reset" => \$opt->{perm_reset} "invite=s@" => \$opt->{invite},
"name=s" => \$opt->{name},
"alias=s" => \$opt->{alias},
"topic=s" => \$opt->{topic},
"join_rules=s" => \$opt->{join_rules},
"federation!" => \$opt->{federation},
"perm=s@" => \$opt->{perm},
"perm_user=s@" => \$opt->{perm_user},
"perm_event=s@" => \$opt->{perm_user},
"perm_reset" => \$opt->{perm_reset}
); );
if (-e File::HomeDir->my_home . "/.patrixrc" && !$opt->{conf}){ if (-e File::HomeDir->my_home . "/.patrixrc" && !$opt->{conf}){
@ -49,6 +58,15 @@ if ($opt->{conf} && -e $opt->{conf}){
read_conf(); read_conf();
} }
# alias for --action=foo is --foo
foreach my $action (qw(send-msg send-notice send-file create-room modify-room
delete-room-alias get-access-token get-room-list get-room-id)){
if ($opt->{$action}){
$opt->{action} = $action;
last;
}
}
my $lwp = LWP::UserAgent->new; my $lwp = LWP::UserAgent->new;
my $stdin = 0; my $stdin = 0;

Loading…
Cancel
Save