Start working on main
This commit is contained in:
parent
d6ccfabdb3
commit
77ff0e98f1
@ -1,4 +1,4 @@
|
|||||||
package Clip;
|
package ClipPass;
|
||||||
|
|
||||||
use Clipboard;
|
use Clipboard;
|
||||||
|
|
13
Password.pm
13
Password.pm
@ -13,12 +13,9 @@ sub new {
|
|||||||
my $db = Database->new();
|
my $db = Database->new();
|
||||||
my $gpg = GPG->new( $ENV{HOME} );
|
my $gpg = GPG->new( $ENV{HOME} );
|
||||||
|
|
||||||
my $p_save = PasswordSave->new();
|
|
||||||
my $p_show = PasswordShow->new();
|
|
||||||
|
|
||||||
my $self = {
|
my $self = {
|
||||||
_db => $db,
|
_db => $db,
|
||||||
_gpg => $gpg,
|
_gpg => $gpg,
|
||||||
};
|
};
|
||||||
|
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
@ -74,7 +71,7 @@ sub save {
|
|||||||
my $mdo_q = {
|
my $mdo_q = {
|
||||||
file => $dec_db_file,
|
file => $dec_db_file,
|
||||||
name => $name,
|
name => $name,
|
||||||
query => $query,
|
query => $q,
|
||||||
type => 'do',
|
type => 'do',
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -102,8 +99,10 @@ sub check_config {
|
|||||||
else {
|
else {
|
||||||
my $db = $self->{_db};
|
my $db = $self->{_db};
|
||||||
$db->create_base();
|
$db->create_base();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
45
pm.pl
45
pm.pl
@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
use Password;
|
use Password;
|
||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
|
use ClipPass;
|
||||||
our $VERSION = '0.0.1a';
|
|
||||||
|
|
||||||
# Debug
|
# Debug
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
|
our $VERSION = '0.0.1a';
|
||||||
|
|
||||||
sub usage() {
|
sub usage() {
|
||||||
print STDERR << "EOF";
|
print STDERR << "EOF";
|
||||||
Simple password manager writed in Perl.
|
Simple password manager writed in Perl.
|
||||||
@ -43,9 +44,12 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub init() {
|
sub init() {
|
||||||
my $opt_string = 'swn:l:p:rhv';
|
my $opt_string = 'swn:l:p:rhvo';
|
||||||
getopts("$opt_string") or usage();
|
getopts("$opt_string") or usage();
|
||||||
our ( $opt_s, $opt_w, $opt_n, $opt_r, $opt_l, $opt_p, $opt_h, $opt_v, $opt_o );
|
our (
|
||||||
|
$opt_s, $opt_w, $opt_n, $opt_r, $opt_l,
|
||||||
|
$opt_p, $opt_h, $opt_v, $opt_o
|
||||||
|
);
|
||||||
|
|
||||||
print "Simple password manager writed in Perl.\nVersion: "
|
print "Simple password manager writed in Perl.\nVersion: "
|
||||||
. $VERSION
|
. $VERSION
|
||||||
@ -61,3 +65,36 @@ my $pass = Password->new();
|
|||||||
|
|
||||||
# Don't use it's before GPG and Database
|
# Don't use it's before GPG and Database
|
||||||
# $pass->check_config() == 0 or die "$!\n";
|
# $pass->check_config() == 0 or die "$!\n";
|
||||||
|
|
||||||
|
my $copy = ClipPass->new();
|
||||||
|
|
||||||
|
# Command line arguments switch
|
||||||
|
if ( defined($opt_s) and defined($opt_n) and !defined($opt_o) ) {
|
||||||
|
|
||||||
|
# Copy password to xclipboard
|
||||||
|
print "$opt_s, $opt_n\n";
|
||||||
|
}
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
elsif ( defined($opt_w)
|
||||||
|
and defined($opt_n)
|
||||||
|
and defined($opt_l)
|
||||||
|
and !defined($opt_p) )
|
||||||
|
{
|
||||||
|
# Generate password and store it into DB
|
||||||
|
print "$opt_w, $opt_n, $opt_l, $opt_p\n";
|
||||||
|
}
|
||||||
|
elsif ( defined($opt_w)
|
||||||
|
and defined($opt_n)
|
||||||
|
and defined($opt_l)
|
||||||
|
and defined($opt_p) )
|
||||||
|
{
|
||||||
|
# Store new password into DB
|
||||||
|
print "$opt_w, $opt_n, $opt_l, $opt_p\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print "FAIL\n" and usage;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user