PM/pm.pl

64 lines
1.5 KiB
Perl
Raw Normal View History

2014-04-27 03:46:32 +04:00
#!/usr/bin/perl
use Password;
use Getopt::Std;
2014-04-28 11:29:38 +04:00
2014-04-28 16:43:00 +04:00
our $VERSION = '0.0.0d';
2014-04-27 03:46:32 +04:00
2014-04-28 11:29:38 +04:00
# Debug
use Data::Dumper;
2014-04-27 03:46:32 +04:00
sub usage() {
2014-04-28 12:17:17 +04:00
print STDERR << "EOF";
2014-04-27 03:46:32 +04:00
Simple password manager writed in Perl.
2014-04-28 16:43:00 +04:00
-s show password
-n [Name of resource] name of resource
-w store new password
-l [Link] link to resource
-p [Password] password
if key not selected PM generate secure password
and copy it to xclipboard
-r remove password
-o open link
-h show this help screen and exit
-v show version info and exit
2014-04-27 03:46:32 +04:00
2014-04-28 11:29:38 +04:00
Examples:
Show password for resource:
\tpm.pl -s -n LOR
2014-04-28 16:43:00 +04:00
\tPassword copied to xclipboard.\n\t\tURI is http://linux.org.ru/
2014-04-28 11:29:38 +04:00
Store new password:
\tpm.pl -w -n PRON -l http://superpronsite.com/ -p my_secret_password
\tPassword for resource PRON is stored into DB!
Copy password and open link:
\tpm.pl -s -n LOR -o
\tPassword copied to clipboard. Trying to open uri.
2014-04-27 03:46:32 +04:00
EOF
2014-04-28 12:17:17 +04:00
exit 1;
2014-04-27 03:46:32 +04:00
}
sub init() {
2014-04-28 12:17:17 +04:00
my $opt_string = 'swn:l:p:rhv';
getopts("$opt_string") or usage();
our ( $opt_s, $opt_w, $opt_n, $opt_r, $opt_l, $opt_p, $opt_h, $opt_v );
print "Simple password manager writed in Perl.\nVersion: "
. $VERSION
. "\n" and exit 0
if $opt_v;
usage if $opt_h;
2014-04-27 03:46:32 +04:00
}
2014-04-28 11:29:38 +04:00
# Parse cmd line
2014-04-28 12:04:17 +04:00
init();
my $pass = Password->new();
2014-04-28 12:17:17 +04:00
2014-04-28 12:04:17 +04:00
# Don't use it's before GPG and Database
2014-04-28 12:17:17 +04:00
# $pass->check_config() == 0 or die "$!\n";