From c2520cdb9f42da700cf8241eb7c4b78308a9f176 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 11 Jun 2011 22:59:58 +0200 Subject: Raps2.pm: pw_add / pw_get: Accept either filename or account name --- lib/App/Raps2.pm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/App/Raps2.pm b/lib/App/Raps2.pm index 6b40cc2..cf5a404 100644 --- a/lib/App/Raps2.pm +++ b/lib/App/Raps2.pm @@ -133,6 +133,8 @@ sub ui { sub pw_add { my ( $self, %data ) = @_; + $data{file} //= $self->{xdg_data} . "/$data{name}"; + my $pass_hash = $self->pw->encrypt( $data{password}, $data{salt} ); my $extra_hash = ( $data{extra} @@ -184,6 +186,8 @@ sub cmd_add { sub pw_get { my ( $self, %data ) = @_; + $data{file} //= $self->{xdg_data} . "/$data{name}"; + my %key = $self->file_to_hash( $data{file} ); return { @@ -414,6 +418,19 @@ Returns the App::Raps2::Password(3pm) object. Returns the App::Raps2::UI(3pm) object. +=item $raps2->pw_add(I<%data>) + +Write an account as specified by I to the store. Requires +B to have been called before. Requires I keys are +password, salt and either file or name, plus the optional url, login and +extra. + +=item $raps2->pw_get(B => I | B => I) + +Loads a password from I (or account I), requires +B to have been called before. Returns a hashref +containing its url, login and decrypted password and extra. + =item $raps2->cmd_add(I<$name>) Adds a new password file called $name. -- cgit v1.2.3