add show count finded records

This commit is contained in:
Alexander Popov 2022-05-02 10:51:25 +03:00
parent f7bb266cac
commit b2ec5fdfe1
Signed by: iiiypuk
GPG Key ID: 3F76816AEE08F908
2 changed files with 14 additions and 10 deletions

View File

@ -9,6 +9,7 @@
## 0.2.3 - [09/04/2022] ## 0.2.3 - [09/04/2022]
- ♻️ - Password outdated date change to 3 month - ♻️ - Password outdated date change to 3 month
- - Added `pmng` logo - - Added `pmng` logo
- - Added show count finded records
## 0.2.2 - [08/04/2022] ## 0.2.2 - [08/04/2022]
- - Added check permissions for password file - - Added check permissions for password file

View File

@ -63,17 +63,11 @@ rescue ex
puts ex.message, "" puts ex.message, ""
end end
# password_file_path = PROGRAM_NAME.split("/") PASSWORD_FILE_PATH = "#{ENV["HOME"]}/.pwd.yml"
# 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 # check password file exists
if File.exists?(password_file_path) if File.exists?(PASSWORD_FILE_PATH)
yaml = File.open(password_file_path) do |file| yaml = File.open(PASSWORD_FILE_PATH) do |file|
YAML.parse(file) YAML.parse(file)
end end
else else
@ -91,7 +85,7 @@ while count < yaml.size
end end
# check file ppermissions # check file ppermissions
password_file_permissions = File.info(password_file_path).permissions.to_s password_file_permissions = File.info(PASSWORD_FILE_PATH).permissions.to_s
if /\d{3}/.match(password_file_permissions).try &.[0] != "600" if /\d{3}/.match(password_file_permissions).try &.[0] != "600"
puts "Password file permissions is not RW for you.".colorize(:red) puts "Password file permissions is not RW for you.".colorize(:red)
@ -158,6 +152,8 @@ while loop
# list search password # list search password
system "clear" system "clear"
passwords_finded_array = 0
passwords_array.each do |item| passwords_array.each do |item|
if item.url.includes?(password_string.to_s) if item.url.includes?(password_string.to_s)
print "🌐 " print "🌐 "
@ -190,9 +186,16 @@ while loop
end end
puts "-----".colorize(:dark_gray).mode(:bold) puts "-----".colorize(:dark_gray).mode(:bold)
passwords_finded_array += 1
end end
end end
end end
puts puts
print "Finded ".colorize(:yellow).mode(:bold)
print passwords_finded_array.colorize(:red).mode(:bold)
puts " records".colorize(:yellow).mode(:bold)
puts "-----".colorize(:dark_gray).mode(:bold)
puts
end end