change pwd path
This commit is contained in:
parent
ce5bca45a3
commit
6fc0459d81
@ -1,5 +1,5 @@
|
||||
name: pmng
|
||||
version: 0.1.0
|
||||
version: 0.2.1
|
||||
|
||||
authors:
|
||||
- Alexander Popov <iiiypuk@iiiypuk.me>
|
||||
|
24
src/pmng.cr
24
src/pmng.cr
@ -2,6 +2,7 @@ require "option_parser"
|
||||
require "yaml"
|
||||
require "colorize"
|
||||
|
||||
# password serializer
|
||||
class Password
|
||||
include YAML::Serializable
|
||||
|
||||
@ -23,6 +24,7 @@ end
|
||||
|
||||
VERSION = "0.2.1"
|
||||
|
||||
# program options
|
||||
begin
|
||||
OptionParser.parse do |parser|
|
||||
parser.banner = "pmng -- ver.: #{VERSION}\nThe very simple password manager for humans\n"
|
||||
@ -50,11 +52,15 @@ rescue ex
|
||||
puts ex.message, ""
|
||||
end
|
||||
|
||||
password_file_path = PROGRAM_NAME.split("/")
|
||||
password_file_path.pop
|
||||
password_file_path.insert(-1, "pwd.yml")
|
||||
password_file_path = password_file_path.join("/")
|
||||
# password_file_path = PROGRAM_NAME.split("/")
|
||||
# password_file_path.pop
|
||||
# password_file_path.insert(-1, "pwd.yml")
|
||||
# password_file_path = password_file_path.join("/")
|
||||
|
||||
# TODO: Fix later
|
||||
password_file_path = "#{ENV["HOME"]}/.pwd.yml"
|
||||
|
||||
# check password file exists
|
||||
if File.exists?(password_file_path)
|
||||
yaml = File.open(password_file_path) do |file|
|
||||
YAML.parse(file)
|
||||
@ -72,22 +78,27 @@ while count < yaml.size
|
||||
count += 1
|
||||
end
|
||||
|
||||
# main loop
|
||||
loop = true
|
||||
while loop
|
||||
# shell prompt
|
||||
print "Enter URL (or :q for exit)\n> "
|
||||
password_string = gets
|
||||
|
||||
# if ':q' to close program
|
||||
if password_string.to_s == ":q"
|
||||
puts "Bye! 👋🏻"
|
||||
exit(0)
|
||||
# if puts empty, retry prompt
|
||||
elsif password_string.to_s.size == 0
|
||||
puts
|
||||
# if ':h' to view help
|
||||
elsif password_string.to_s == ":h"
|
||||
puts "Help:\n-----"
|
||||
puts ":s - Return stats"
|
||||
|
||||
# if ':s' to view Statistics
|
||||
elsif password_string.to_s == ":s"
|
||||
puts "Statictics:\n----------"
|
||||
puts "Statistics:\n----------"
|
||||
print "Elements: ".colorize(:yellow)
|
||||
puts new_array.size
|
||||
|
||||
@ -103,6 +114,7 @@ while loop
|
||||
end
|
||||
|
||||
puts outdated_count
|
||||
# list search password
|
||||
else
|
||||
new_array.each do |item|
|
||||
if item.url.includes?(password_string.to_s)
|
||||
|
Loading…
Reference in New Issue
Block a user