Initial commit
This commit is contained in:
commit
8d12b191d5
42
Password.pm
Normal file
42
Password.pm
Normal file
@ -0,0 +1,42 @@
|
||||
package Password;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
|
||||
use DBI;
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
|
||||
# Get home dir
|
||||
$home = $ENV{HOME};
|
||||
|
||||
my $self = {
|
||||
_home => $home,
|
||||
};
|
||||
|
||||
bless $self, $class;
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub create_base {
|
||||
my $self = shift;
|
||||
my $home = $self->{_home};
|
||||
my $pm_dir = $home."/.PM/";
|
||||
|
||||
# Check dir
|
||||
if !(-d $pm_dir) {
|
||||
# Create dirrectory
|
||||
@cmd_string = ("mkdir", "$pm_dir");
|
||||
system(@cmd_string) == 0 or die "Cannot create dir $pm_dir: $!\n";
|
||||
# Create database. TODO: write this
|
||||
my $dbi = DBI->connect("DBD::sqlite");
|
||||
}
|
||||
else {
|
||||
print "dirrectory is exist!\n";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
12
PasswordSave.pm
Normal file
12
PasswordSave.pm
Normal file
@ -0,0 +1,12 @@
|
||||
package PasswordSave;
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $self = {
|
||||
_name => shift,
|
||||
};
|
||||
bless $self, $class;
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
14
PasswordShow.pm
Normal file
14
PasswordShow.pm
Normal file
@ -0,0 +1,14 @@
|
||||
package PasswordShow;
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $self = {
|
||||
_name => shift,
|
||||
};
|
||||
bless $self, $class;
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
35
pm.pl
Normal file
35
pm.pl
Normal file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use Password;
|
||||
|
||||
use Getopt::Std;
|
||||
# Global
|
||||
use vars qw / %opt /;
|
||||
our $VERSION = '0.0.0a';
|
||||
|
||||
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
|
||||
-h -- Show this help screen and exit
|
||||
-v -- Show version info and exit
|
||||
|
||||
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};
|
||||
}
|
||||
|
||||
init();
|
Loading…
Reference in New Issue
Block a user