Init 🏁
This commit is contained in:
87
src/passw0rd_manager.cr
Normal file
87
src/passw0rd_manager.cr
Normal file
@@ -0,0 +1,87 @@
|
||||
require "yaml"
|
||||
require "colorize"
|
||||
|
||||
class Password
|
||||
include YAML::Serializable
|
||||
|
||||
@[YAML::Field(key: "url")]
|
||||
property url : String
|
||||
@[YAML::Field(key: "email")]
|
||||
property email : String
|
||||
@[YAML::Field(key: "login")]
|
||||
property login : String
|
||||
@[YAML::Field(key: "password")]
|
||||
property password : String
|
||||
@[YAML::Field(key: "desc")]
|
||||
property desc : String
|
||||
@[YAML::Field(key: "profile_url")]
|
||||
property profile_url : String
|
||||
@[YAML::Field(key: "update")]
|
||||
property update : Int32
|
||||
end
|
||||
|
||||
VERSION = "0.1.0"
|
||||
|
||||
if !File.exists?("pwd.yml")
|
||||
puts "No password.yml file exists."
|
||||
|
||||
exit(1)
|
||||
end
|
||||
|
||||
yaml = File.open("pwd.yml") do |file|
|
||||
YAML.parse(file)
|
||||
end
|
||||
|
||||
new_array = [] of Password
|
||||
count = 0
|
||||
while count < yaml.size
|
||||
new_array << Password.from_yaml(yaml[count].to_yaml)
|
||||
count += 1
|
||||
end
|
||||
|
||||
while true
|
||||
print "Enter URL (or :q for exit)\n> "
|
||||
password_string = gets
|
||||
|
||||
if password_string.to_s == ":q"
|
||||
puts "Bye! 👋🏻"
|
||||
|
||||
exit(0)
|
||||
elsif password_string.to_s == ":h"
|
||||
puts "Help:\n-----"
|
||||
puts ":s - return stats"
|
||||
|
||||
puts
|
||||
elsif password_string.to_s == ":s"
|
||||
print "Elements: "
|
||||
puts new_array.size
|
||||
|
||||
puts
|
||||
end
|
||||
|
||||
new_array.each do |item|
|
||||
if item.url.includes?(password_string.to_s)
|
||||
puts item.url.colorize(:magenta).mode(:blink)
|
||||
|
||||
if !item.email.blank?
|
||||
puts item.email.colorize(:red)
|
||||
end
|
||||
if !item.login.blank?
|
||||
puts item.login.colorize(:yellow)
|
||||
end
|
||||
if !item.password.blank?
|
||||
puts item.password.colorize(:red).back(:red)
|
||||
end
|
||||
if !item.desc.blank?
|
||||
puts item.desc.colorize(:cyan)
|
||||
end
|
||||
if !item.profile_url.blank?
|
||||
puts item.profile_url.colorize(:green)
|
||||
end
|
||||
|
||||
puts "---".colorize(:dark_gray)
|
||||
end
|
||||
end
|
||||
|
||||
puts
|
||||
end
|
||||
Reference in New Issue
Block a user