commit bd71caf68080238bb0f9395d28a68fa3adf3f44d from: Omar Polo date: Wed Jun 29 11:25:13 2022 UTC drop the 'regen' command too 'gen' now is happy to override files. since we're using a version control system anyway, there's no point in being picky about changing files. If one overrides a password by mistake, the old one is still available thanks to got. commit - f96edc2510f43ce54ae271614ea2a4d751057d23 commit + bd71caf68080238bb0f9395d28a68fa3adf3f44d blob - 9dc01d186e7019fb0f3759684885e6b0142957af blob + cf4db6ba9ab4776d921abba8bd3b0880820b0725 --- 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"], - regen => [\&cmd_regen, "[-c chars] [-l length] entry"], rm => [\&cmd_rm, "entry"], tee => [\&cmd_tee, "[-q] entry"], tog => [\&cmd_tog, "arguments ..."], @@ -229,14 +228,14 @@ sub cmd_gen { my $name = shift @ARGV; my $file = name2file $name; - die "password already exists: $file\n" if -e $file; + my $renamed = -f $file; my $pass = gen($chars, $length); unless ($nop) { writepass($file, $pass); got_add $file; - got_ci "+$name"; + got_ci($renamed ? "update $name" : "+$name"); } say $pass unless $q; } @@ -263,32 +262,10 @@ sub cmd_mv { rename $pa, $pb or die "can't rename $a to $b: $!"; got_rm $pa; - got_add $pb; + got_add $pb or die "can't add $pb\n"; got_ci "mv $a $b"; } -sub cmd_regen { - 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 1; - - my $name = shift @ARGV; - my $file = name2file $name; - die "password doesn't exist" unless -f $file; - - my $pass = gen($chars, $length); - writepass($file, $pass); - - got_add $file; - got_ci "regen $name"; -} - sub cmd_rm { GetOptions('h|?' => \&usage) or usage; usage if @ARGV ne 1; @@ -334,7 +311,7 @@ B - manage passwords B I [-h] [arg ...] -Valid subcommands are: cat, find, gen, got, mv, regen, rm, tee, tog. +Valid subcommands are: cat, find, gen, got, mv, rm, tee, tog. =head1 DESCRIPTION @@ -382,10 +359,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] I - -Like B but re-generates a password in-place. - =item B I Remove the password I from the store.