From 8d12b191d5a80027eaf76b0332e1247cf817c5b8 Mon Sep 17 00:00:00 2001 From: anna Date: Sun, 27 Apr 2014 03:46:32 +0400 Subject: [PATCH] Initial commit --- Password.pm | 42 ++++++++++++++++++++++++++++++++++++++++++ PasswordSave.pm | 12 ++++++++++++ PasswordShow.pm | 14 ++++++++++++++ pm.pl | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 Password.pm create mode 100644 PasswordSave.pm create mode 100644 PasswordShow.pm create mode 100644 pm.pl diff --git a/Password.pm b/Password.pm new file mode 100644 index 0000000..ab9864e --- /dev/null +++ b/Password.pm @@ -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; \ No newline at end of file diff --git a/PasswordSave.pm b/PasswordSave.pm new file mode 100644 index 0000000..a82967f --- /dev/null +++ b/PasswordSave.pm @@ -0,0 +1,12 @@ +package PasswordSave; + +sub new { + my $class = shift; + my $self = { + _name => shift, + }; + bless $self, $class; + return $self; +} + +1; \ No newline at end of file diff --git a/PasswordShow.pm b/PasswordShow.pm new file mode 100644 index 0000000..a73d023 --- /dev/null +++ b/PasswordShow.pm @@ -0,0 +1,14 @@ +package PasswordShow; + +sub new { + my $class = shift; + my $self = { + _name => shift, + }; + bless $self, $class; + return $self; +} + + + +1; \ No newline at end of file diff --git a/pm.pl b/pm.pl new file mode 100644 index 0000000..efc0378 --- /dev/null +++ b/pm.pl @@ -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();