App-Raps2

 view release on metacpan or  search on metacpan

Changelog  view on Meta::CPAN

    [App::Raps2]
    * new: Add pwgen_cmd argument
    * Add create_defaults, load_defaults, conf and generate_password methods
    * pw_save: Add optional cost argument
    * pw_load, pw_load_info: Now also return the key setup cost

    [App::Raps2::Password]
    * encrypt, decrypt: Now take hash as argument, keys are data/salt/cost

    [App::Raps2::UI]
    * to_clipboard: Return undef if xclip dosn't run, true otherwise

App::Raps2 0.50 - Fri Jul 08 2011

    * Switch to perl version scheme
    * Remove Test::MockObject dependency
    * Declare Test::Fatal dependency

    [App::Raps2]
    * Move cmd_* functions into raps2
    * Rename pw_add t pw_save

bin/raps2  view on Meta::CPAN

	if ( length($pass) == 0 ) {
		$pass = $raps2->generate_password();

		if ( not $pass ) {
			say STDERR "Password generation failed: ${!}: "
			  . $raps2->conf('pwgen_cmd');
			exit 3;
		}

		if ($paste) {
			$raps2->ui->to_clipboard( $pass, $raps2->conf('xclip_cmd') );
		}
		elsif ( not $no_echo ) {
			$raps2->ui->output( [ 'Generated password', $pass ] );
		}
	}

	$raps2->pw_save(
		file     => $pwfile,
		url      => $url,
		login    => $login,

bin/raps2  view on Meta::CPAN

	}

	my $pwfile = data_files("raps2/${name}");

	file_must_exist( $pwfile, $name );

	$raps2->get_master_password();

	my $key = $raps2->pw_load( file => $pwfile );

	$raps2->ui->to_clipboard( $key->{password}, $raps2->conf('xclip_cmd') )
	  or die("Could not place password in clipboard: ${!}\n");

	if ( $key->{extra} ) {
		print $key->{extra};
	}

	return;
}

sub cmd_help {
	my ( $exit_status, $subcmd ) = @_;

bin/raps2  view on Meta::CPAN

=item B<cost> = 12

Default key setup cost.  See the B<-c> option.

=item B<pwgen_cmd> = pwgen -s 23 1

Command used to generate passwords.  See the B<-p> option.

=item B<xclip_cmd> = xclip -l 1

Command used to place passwords in the clipboard.  See the B<-x> option.

=back

Note that commandline arguments always override options set in the
configuration file.

=head1 DEPENDENCIES

=over

lib/App/Raps2/UI.pm  view on Meta::CPAN


	if ( $verify and $in1 ne $in2 ) {
		confess('Input lines did not match');
	}

	chomp $in1;

	return $in1;
}

sub to_clipboard {
	my ( $self, $str, $cmd ) = @_;

	$cmd //= 'xclip -l 1';

	open( my $clipboard, q{|-}, $cmd )
	  or return;

	print $clipboard $str;

	close($clipboard)
	  or cluck("Failed to close pipe to ${cmd}: ${!}");

	return 1;
}

sub output {
	my ( $self, @out ) = @_;

	for my $pair (@out) {
		printf( "%-8s : %s\n", $pair->[0], $pair->[1] // q{}, );

lib/App/Raps2/UI.pm  view on Meta::CPAN

App::Raps2::UI - App::Raps2 User Interface

=head1 SYNOPSIS

    my $ui = App::Raps2::UI->new();

    my $input = $ui->read_line('Say something');

    my $password = $ui->read_pw('New password', 1);

    $ui->to_clipboard('stuff!');

=head1 VERSION

This manual documents B<App::Raps2::UI> version 0.54

=head1 DESCRIPTION

App::Raps2::UI is used by App::Raps2 to interface with the user, i.e. do input
and output on the terminal.

lib/App/Raps2/UI.pm  view on Meta::CPAN

Like B<read_line>, but repeats I<message> each time the user hits return.
Input is terminated by EOF (Ctrl+D).  Returns a string concatenation of all
lines (including newlines).

=item $ui->read_pw(I<$message>, I<$verify>)

Prompt the user for a password. I<message> is displayed, the user's input is
noch echoed.  If I<verify> is set, the user has to enter the same input twice,
otherwise B<read_pw> dies.  Returns the input.

=item $ui->to_clipboard(I<$string>, [I<command>])

Call I<command> to place I<string> in the primary X Clipboard.  I<command>
defaults to C<< xclip -l 1 >>.

Returns true upon success, undef if the operation failed. Use $! to get the
error message.

=item $ui->output(I<\@pair>, I<...>)

I<pair> consinsts of B<[> I<key>, I<value> B<]>. For each I<pair>, prints



( run in 1.757 second using v1.01-cache-2.11-cpan-df04353d9ac )