add exceptions parse for OptionParser
This commit is contained in:
parent
e067e2cb24
commit
5d7fca4096
@ -23,27 +23,31 @@ end
|
||||
|
||||
VERSION = "0.1.0"
|
||||
|
||||
OptionParser.parse do |parser|
|
||||
parser.banner = "Welcome to The Beatles App!"
|
||||
begin
|
||||
OptionParser.parse do |parser|
|
||||
parser.banner = "Welcome to The Beatles App!"
|
||||
|
||||
parser.on "-v", "--version", "Show version" do
|
||||
puts "Version #{VERSION}"
|
||||
exit
|
||||
end
|
||||
parser.on "-h", "--help", "Show help" do
|
||||
puts 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)
|
||||
exit
|
||||
end
|
||||
parser.on "-t", "--unixtime", "Return local timestamp" do
|
||||
puts Time.local.to_unix
|
||||
exit
|
||||
parser.on "-v", "--version", "Show version" do
|
||||
puts "Version #{VERSION}"
|
||||
exit
|
||||
end
|
||||
parser.on "-h", "--help", "Show help" do
|
||||
puts parser
|
||||
exit
|
||||
end
|
||||
parser.on "-g", "--generate-password", "Generate password" do
|
||||
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.colorize(:yellow)
|
||||
exit
|
||||
end
|
||||
end
|
||||
rescue ex
|
||||
puts ex.message, ""
|
||||
end
|
||||
|
||||
if !File.exists?("pwd.yml")
|
||||
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user