diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-07-20 20:04:39 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-07-20 20:04:39 +0200 |
commit | 502d16d247c10b33b86b9fa8bbc389f88e8f47c5 (patch) | |
tree | a038e3ff9ca8485c87048e26da42ecda75c42ae5 | |
parent | d40f159f56eb098a9ddf082ebd64b414e2e8801d (diff) |
raps2: Add cost/echo/pwgen options
-rwxr-xr-x | bin/raps2 | 20 | ||||
-rw-r--r-- | lib/App/Raps2.pm | 8 |
2 files changed, 20 insertions, 8 deletions
@@ -11,17 +11,25 @@ use File::BaseDir qw(data_files data_home); use File::Slurp qw(read_dir); use Getopt::Long qw(:config no_ignore_case); -my $raps2 = App::Raps2->new(); -my ( $action, @args ) = @ARGV; +my ( $default_cost, $echo_generated, $pwgen_cmd ); our $VERSION = '0.50'; GetOptions( - 'h|help' => sub { cmd_help(0) }, - 'V|version' => sub { say "raps2 version ${VERSION}"; exit 0 }, + 'c|cost=i' => \$default_cost, + 'e|echo' => \$echo_generated, + 'h|help' => sub { cmd_help(0) }, + 'p|pwgen_cmd=s' => \$pwgen_cmd, + 'V|version' => sub { say "raps2 version ${VERSION}"; exit 0 }, ) or cmd_help(1); +my ( $action, @args ) = @ARGV; +my $raps2 = App::Raps2->new( + cost => $default_cost, + pwgen_cmd => $pwgen_cmd +); + sub file_must_exist { my ( $file, $name ) = @_; @@ -70,6 +78,10 @@ sub cmd_add { . $raps2->conf('pwgen_cmd'); exit 3; } + + if ($echo_generated) { + $raps2->ui->output( [ 'Generated password', $pass ] ); + } } $raps2->pw_save( diff --git a/lib/App/Raps2.pm b/lib/App/Raps2.pm index d173adc..897e62e 100644 --- a/lib/App/Raps2.pm +++ b/lib/App/Raps2.pm @@ -96,8 +96,8 @@ sub create_config { my $cost = $self->{master_cost} = $self->{default}{cost} // 12; - my $pass = $self->{default}{master_password} - // $self->ui->read_pw( 'Master Password', 1 ); + my $pass = $self->{default}{master_password} // $self->ui->read_pw( + 'Running for the first time. Please choose a master password', 1 ); $self->{pass} = App::Raps2::Password->new( cost => $self->{master_cost}, @@ -149,8 +149,8 @@ sub load_defaults { my $cfg = Config::Tiny->read( $self->{xdg_conf} . '/defaults' ); - $self->{default}{cost} = $cfg->{_}->{cost}; - $self->{default}{pwgen_cmd} = $cfg->{_}->{pwgen_cmd}; + $self->{default}{cost} //= $cfg->{_}->{cost}; + $self->{default}{pwgen_cmd} //= $cfg->{_}->{pwgen_cmd}; return; } |