From 8f4618b8cbce27e8042c4119c1e8e110771ac310 Mon Sep 17 00:00:00 2001 From: Difrex Date: Mon, 5 May 2014 22:55:27 +0400 Subject: [PATCH] Show password now must be worked. But I'm not tested it. --- README.md | 9 +++++---- pm.pl | 19 ++++++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8ce3e7c..f2ad4bc 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,11 @@ PM Simple password manager writed in perl. -== INSTALL == - -=== Perl modules === +INSTALL +======= +Perl modules +=== cpan install Module::Name. Not recommended. Please use you package manager. @@ -20,7 +21,7 @@ On Fedora: On Debian-based systems: - I'm don't have it now. + I'm don't have it now :) TODO diff --git a/pm.pl b/pm.pl index 5d12b36..7b04a1c 100755 --- a/pm.pl +++ b/pm.pl @@ -7,7 +7,7 @@ use ClipPass; # Debug use Data::Dumper; -our $VERSION = '0.0.1a'; +our $VERSION = '0.0.1b'; sub usage() { print STDERR << "EOF"; @@ -69,15 +69,24 @@ init(); my $copy = ClipPass->new(); # Command line arguments switch +# It's really ugly code. Sorry :( if ( defined($opt_s) and defined($opt_n) and !defined($opt_o) ) { - # Copy password to xclipboard - print "$opt_s, $opt_n\n"; + my $get_h = $pass->show($opt_n); + $copy->copy($get_h->{password}); + + print "Password copied to xclipboard.\nURI is " . $get_h->{resource}; } elsif ( defined($opt_s) and defined($opt_n) and defined($opt_o) ) { - # Copy password to xclipboard and open the uri - print "$opt_s, $opt_n, $opt_o\n"; + my $get_h = $pass->show($opt_n); + $copy->copy($get_h->{password}); + + # Open resource. + my @open_cmd = ('xdg-open', $get_h->{resource}); + system(@open_cmd) == 0 or die "Cannot open URI: $!\n"; + + print "Password copied to clipboard. Trying to open uri.\n"; } elsif ( defined($opt_w) and defined($opt_n)