add exceptions parse for OptionParser
This commit is contained in:
parent
e067e2cb24
commit
5d7fca4096
@ -23,27 +23,31 @@ end
|
|||||||
|
|
||||||
VERSION = "0.1.0"
|
VERSION = "0.1.0"
|
||||||
|
|
||||||
OptionParser.parse do |parser|
|
begin
|
||||||
parser.banner = "Welcome to The Beatles App!"
|
OptionParser.parse do |parser|
|
||||||
|
parser.banner = "Welcome to The Beatles App!"
|
||||||
|
|
||||||
parser.on "-v", "--version", "Show version" do
|
parser.on "-v", "--version", "Show version" do
|
||||||
puts "Version #{VERSION}"
|
puts "Version #{VERSION}"
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
parser.on "-h", "--help", "Show help" do
|
parser.on "-h", "--help", "Show help" do
|
||||||
puts parser
|
puts parser
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
parser.on "-g", "--generate-password", "Generate password" do
|
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).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).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(:white).back(:blue)
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
parser.on "-t", "--unixtime", "Return local timestamp" do
|
parser.on "-t", "--unixtime", "Return local timestamp" do
|
||||||
puts Time.local.to_unix
|
puts Time.local.to_unix.colorize(:yellow)
|
||||||
exit
|
exit
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
rescue ex
|
||||||
|
puts ex.message, ""
|
||||||
end
|
end
|
||||||
|
|
||||||
if !File.exists?("pwd.yml")
|
if !File.exists?("pwd.yml")
|
||||||
@ -69,13 +73,13 @@ while true
|
|||||||
|
|
||||||
if password_string.to_s == ":q"
|
if password_string.to_s == ":q"
|
||||||
puts "Bye! 👋🏻"
|
puts "Bye! 👋🏻"
|
||||||
|
exit
|
||||||
exit(0)
|
|
||||||
elsif password_string.to_s == ":h"
|
elsif password_string.to_s == ":h"
|
||||||
puts "Help:\n-----"
|
puts "Help:\n-----"
|
||||||
puts "\t:s - Return stats"
|
puts ":s - Return stats"
|
||||||
|
|
||||||
elsif password_string.to_s == ":s"
|
elsif password_string.to_s == ":s"
|
||||||
|
puts "Statictics:\n----------"
|
||||||
print "Elements: ".colorize(:yellow)
|
print "Elements: ".colorize(:yellow)
|
||||||
puts new_array.size
|
puts new_array.size
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user