add exceptions parse for OptionParser

This commit is contained in:
Alexander Popov 2022-01-03 23:47:06 +03:00
parent e067e2cb24
commit 5d7fca4096

View File

@ -23,6 +23,7 @@ end
VERSION = "0.1.0"
begin
OptionParser.parse do |parser|
parser.banner = "Welcome to The Beatles App!"
@ -35,16 +36,19 @@ OptionParser.parse do |parser|
exit
end
parser.on "-g", "--generate-password", "Generate password" do
puts Random::Secure.urlsafe_base64(16, padding: false).to_s.colorize(:black).back(:white)
puts Random::Secure.urlsafe_base64(16, padding: false).to_s.colorize(:white).back(:red)
puts Random::Secure.urlsafe_base64(16, padding: false).to_s.colorize(:white).back(:blue)
puts Random::Secure.urlsafe_base64(16, padding: false).colorize(:black).back(:white)
puts Random::Secure.urlsafe_base64(16, padding: false).colorize(:white).back(:red)
puts Random::Secure.urlsafe_base64(16, padding: false).colorize(:white).back(:blue)
exit
end
parser.on "-t", "--unixtime", "Return local timestamp" do
puts Time.local.to_unix
puts Time.local.to_unix.colorize(:yellow)
exit
end
end
rescue ex
puts ex.message, ""
end
if !File.exists?("pwd.yml")
puts "No password.yml file exists."
@ -69,13 +73,13 @@ while true
if password_string.to_s == ":q"
puts "Bye! 👋🏻"
exit(0)
exit
elsif password_string.to_s == ":h"
puts "Help:\n-----"
puts "\t:s - Return stats"
puts ":s - Return stats"
elsif password_string.to_s == ":s"
puts "Statictics:\n----------"
print "Elements: ".colorize(:yellow)
puts new_array.size