diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-05-16 11:22:01 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-05-16 11:22:01 +0200 |
commit | 86d8310d5724632f2cd54723e9a2ced66bb80ba9 (patch) | |
tree | eaea2df4240599af05bfbd499b541ba6545d8170 | |
parent | 06d064c1d6ba7a98c32527c0ca865c73fd65458e (diff) |
Use Term::ReadLine instead of builtin readline
-rw-r--r-- | Build.PL | 1 | ||||
-rw-r--r-- | Changelog | 4 | ||||
-rw-r--r-- | lib/App/Raps2.pm | 10 | ||||
-rw-r--r-- | lib/App/Raps2/UI.pm | 14 |
4 files changed, 18 insertions, 11 deletions
@@ -24,6 +24,7 @@ my $build = Module::Build->new( 'File::Path' => 2.06_05, 'File::Slurp' => 0, 'POSIX' => 0, + 'Term::ReadLine' => 0, }, script_files => 'bin/', sign => 1, @@ -1,3 +1,7 @@ +git HEAD + + * Terminal input is now read via Term::ReadLine (included in perl core) + raps2 0.2 - Fri May 13 2011 * Fix XDG_CONFIG_HOME / XDG_DATA_HOME handling bug. Adds new dependency diff --git a/lib/App/Raps2.pm b/lib/App/Raps2.pm index 273abee..32e46f6 100644 --- a/lib/App/Raps2.pm +++ b/lib/App/Raps2.pm @@ -224,11 +224,11 @@ sub cmd_add { $self->get_master_password(); - my $salt = $self->create_salt(); - my $url = $self->ui()->read_line('URL'); - my $login = $self->ui()->read_line('Login'); - my $pass = $self->ui()->read_pw('Password', 1); - my $extra = $self->ui()->read_multiline('Additional content'); + my $salt = $self->create_salt(); + my $url = $self->ui->read_line('URL'); + my $login = $self->ui->read_line('Login'); + my $pass = $self->ui->read_pw('Password', 1); + my $extra = $self->ui->read_multiline('Additional content'); $self->{pass}->salt($salt); my $pass_hash = $self->{pass}->encrypt($pass); diff --git a/lib/App/Raps2/UI.pm b/lib/App/Raps2/UI.pm index 5192c43..089290b 100644 --- a/lib/App/Raps2/UI.pm +++ b/lib/App/Raps2/UI.pm @@ -7,12 +7,14 @@ use 5.010; use Carp qw(confess); use POSIX; +use Term::ReadLine; our $VERSION = '0.2'; sub new { my ($obj) = @_; my $ref = {}; + $ref->{term_readline} = Term::ReadLine->new('App::Raps2'); return bless($ref, $obj); } @@ -28,12 +30,12 @@ sub list { } sub read_line { - my ($self, $str) = @_; + my ($self, $str, $pre) = @_; - print "${str}: "; - my $input = readline(STDIN); + $pre //= q{}; + + my $input = $self->{term_readline}->readline("${str}: ${pre}"); - chomp $input; return $input; } @@ -43,8 +45,8 @@ sub read_multiline { say "${str} (^D to quit)"; - while (my $line = <STDIN>) { - $in .= $line; + while (my $line = $self->read_line('multiline')) { + $in .= "${line}\n"; } return $in; } |