Prompt for the password if not given as arg, nor in the conf file

tags/patrix-0.1.4-1
Daniel Berteaud 7 years ago
parent bd94a96e1e
commit f5892003ff
  1. 11
      scripts/patrix

@ -12,6 +12,7 @@ use File::MimeInfo;
use File::Basename;
use URI::Escape;
use Path::Tiny;
use Term::ReadKey;
our $opt;
@ -53,6 +54,16 @@ $opt->{server} //= 'matrix.org';
$opt->{action} //= 'send-msg';
$opt->{federation} //= 1;
# Prompt to enter the password
if (!$opt->{access_token} && $opt->{user} && !$opt->{password}){
ReadMode('noecho');
print "Password: ";
$opt->{password} = ReadLine(0);
$opt->{password} =~ s/\R\z//;
ReadMode('restore');
print "\n";
}
# Check we have all the options we need
if ($opt->{action} eq 'get-access-token' && (!$opt->{user} || !$opt->{password})){
die "You need to provide a valid user and password to get an access token\n\n";

Loading…
Cancel
Save