From 82d6608c596e3f4d28351b8975b1f0b2c4a8b8f5 Mon Sep 17 00:00:00 2001 From: "Difrex(Denis Zheleztsov)" Date: Mon, 28 Apr 2014 11:29:38 +0400 Subject: [PATCH] Usage and getopts writed --- pm.pl | 49 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 14 deletions(-) mode change 100644 => 100755 pm.pl diff --git a/pm.pl b/pm.pl old mode 100644 new mode 100755 index efc0378..5702d78 --- a/pm.pl +++ b/pm.pl @@ -1,35 +1,56 @@ #!/usr/bin/perl use Password; - use Getopt::Std; -# Global -use vars qw / %opt /; + our $VERSION = '0.0.0a'; +# Debug +use Data::Dumper; + sub usage() { print STDERR << "EOF"; Simple password manager writed in Perl. Usage: - - -s [Name of resource] -- Show password for resource - -w -- Store new password(interactive) - -W [Name|Link|password] -- Non interactive - -r [Name] -- Remove password + -s -- Show password + -n [Name of resource] -- Name of resource + -w -- Store new password + -l [Link] -- Link to resource + -p [Password] -- Password + -r -- Remove password + -o -- Open link -h -- Show this help screen 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 exit 1; } sub init() { - my $opt_string = 'swWrhv'; - # TODO: switch's to Getopt::Mixed - getopts("$opt_string", \%opt) or usage(); - print STDOUT "Simple password manager writed in Perl.\nVersion: ".$VERSION . "\n" and exit 0 if $opt{v}; - usage if $opt{h}; + 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; } -init(); +# Parse cmd line +init(); \ No newline at end of file