Usage and getopts writed
This commit is contained in:
parent
7dc29874a6
commit
82d6608c59
47
pm.pl
Normal file → Executable file
47
pm.pl
Normal file → Executable file
@ -1,35 +1,56 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
use Password;
|
use Password;
|
||||||
|
|
||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
# Global
|
|
||||||
use vars qw / %opt /;
|
|
||||||
our $VERSION = '0.0.0a';
|
our $VERSION = '0.0.0a';
|
||||||
|
|
||||||
|
# Debug
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
sub usage() {
|
sub usage() {
|
||||||
print STDERR << "EOF";
|
print STDERR << "EOF";
|
||||||
Simple password manager writed in Perl.
|
Simple password manager writed in Perl.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
-s -- Show password
|
||||||
-s [Name of resource] -- Show password for resource
|
-n [Name of resource] -- Name of resource
|
||||||
-w -- Store new password(interactive)
|
-w -- Store new password
|
||||||
-W [Name|Link|password] -- Non interactive
|
-l [Link] -- Link to resource
|
||||||
-r [Name] -- Remove password
|
-p [Password] -- Password
|
||||||
|
-r -- Remove password
|
||||||
|
-o -- Open link
|
||||||
-h -- Show this help screen and exit
|
-h -- Show this help screen and exit
|
||||||
-v -- Show version info and exit
|
-v -- Show version info and exit
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
Show password for resource:
|
||||||
|
\tpm.pl -s -n LOR
|
||||||
|
\tPassword copied to xclipboard.\n\t\tLink is http://linux.org.ru/
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub init() {
|
sub init() {
|
||||||
my $opt_string = 'swWrhv';
|
my $opt_string = 'swn:l:p:rhv';
|
||||||
# TODO: switch's to Getopt::Mixed
|
getopts("$opt_string") or usage();
|
||||||
getopts("$opt_string", \%opt) or usage();
|
our ($opt_s, $opt_w, $opt_n, $opt_r,
|
||||||
print STDOUT "Simple password manager writed in Perl.\nVersion: ".$VERSION . "\n" and exit 0 if $opt{v};
|
$opt_l, $opt_p, $opt_h, $opt_v);
|
||||||
usage if $opt{h};
|
|
||||||
|
print "Simple password manager writed in Perl.\nVersion: ".
|
||||||
|
$VERSION."\n" and exit 0 if $opt_v;
|
||||||
|
usage if $opt_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Parse cmd line
|
||||||
init();
|
init();
|
Loading…
Reference in New Issue
Block a user