commit 9d75d6d8b9b213f880edb88cfe731cf76031afbc from: Omar Polo date: Wed Jun 29 11:15:00 2022 UTC remove the 'oneshot' command and augment 'gen' gen now has a -n option for no-op that avoids persisting the password and now prints the generated password by default. This comes in handy in various cases, for example now it's possible to: $ plass gen foobar | clip A foobar2.gpg Created commit c1d55a274bd28103271a7e4d0c4f83266fc14926 Like the 'tee' subcommand, add -q to suppress printing the password if desired. commit - 87197963c50542b16a624c522fd3a2e6829d9f0e commit + 9d75d6d8b9b213f880edb88cfe731cf76031afbc blob - cdfdaba4145103be38cd39a743b8c26c2fedb626 blob + 0f82b02f7532fe26523d5be6137ee0c72257304a --- plass +++ plass @@ -51,7 +51,6 @@ my %subcmd = ( gen => [\&cmd_gen, "[-c chars] [-l length] entry"], got => [\&cmd_got, "arguments ..."], mv => [\&cmd_mv, "from to"], - oneshot => [\&cmd_oneshot, "[-c chars] [-l length]"], regen => [\&cmd_regen, "[-c chars] [-l length] entry"], rm => [\&cmd_rm, "entry"], tee => [\&cmd_tee, "[-q] entry"], @@ -215,11 +214,15 @@ sub cmd_find { sub cmd_gen { my $chars = $default_chars; my $length = $default_length; + my $nop; + my $q; GetOptions( 'c=s' => sub { $chars = $_[1] }, 'h|?' => \&usage, 'l=i' => sub { $length = $_[1] }, + 'n' => \$nop, + 'q' => \$q, ) or usage; usage if @ARGV ne 1; @@ -228,10 +231,13 @@ sub cmd_gen { die "password already exists: $file\n" if -e $file; my $pass = gen($chars, $length); - writepass($file, $pass); - got_add $file; - got_ci "+$name"; + unless ($nop) { + writepass($file, $pass); + got_add $file; + got_ci "+$name"; + } + say $pass unless $q; } sub cmd_got { @@ -258,20 +264,6 @@ sub cmd_mv { got_rm $pa; got_add $pb; got_ci "mv $a $b"; -} - -sub cmd_oneshot { - my $chars = $default_chars; - my $length = $default_length; - - GetOptions( - 'c=s' => sub { $chars = $_[1] }, - 'h|?' => \&usage, - 'l=i' => sub { $length = $_[1] }, - ) or usage; - usage if @ARGV ne 0; - - say gen($chars, $length); } sub cmd_regen { @@ -341,8 +333,7 @@ B - manage passwords B I [-h] [arg ...] -Valid subcommands are: cat, find, gen, got, mv, oneshot, regen, rm, -tee, tog. +Valid subcommands are: cat, find, gen, got, mv, regen, rm, tee, tog. =head1 DESCRIPTION @@ -369,13 +360,17 @@ Decrypt and print the passwords of the given I. -=item B [B<-c> I] [B<-l> I] I +=item B [B<-nq>] [B<-c> I] [B<-l> I] I Generate and persist a password for the given I in the store. B<-c> can be used to control the characters allowed in the password (by default I i.e. all the printable ASCII character) and B<-l> the length (32 by default.) +Unless B<-q> is provided, plass prints the generated password. + +If the B<-n> option is given, plass won't persist the password. + =item B I Execute got(1) in the password store directory with the given @@ -386,11 +381,6 @@ I. Rename a password entry, doesn't work with directories. I must exist and I mustn't. -=item B [B<-c> I] [B<-l> I] - -Like B but prints the the generated password instead of persist -it. - =item B [B<-c> I] [B<-l> I] I Like B but re-generates a password in-place.