Skip to content

Commit

Permalink
print usage when passing invalid args
Browse files Browse the repository at this point in the history
  • Loading branch information
zw963 committed Oct 10, 2024
1 parent c771a92 commit 0e5a773
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/cli.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ ip111 = false
ip138 = false
ipsb = false

OptionParser.parse do |parser|
parser.banner = <<-USAGE
usage = <<-USAGE
Usage:
myip ip111 => get ip from http://www.ip111.cn
myip ip138 => get ip info from https://www.ip138.com
myip ipsb => get ip info from https://api.ip.sb/geoip
USAGE

OptionParser.parse do |parser|
parser.banner = usage
parser.on("-h", "--help", "Show this help message and exit") do
puts parser
exit
Expand Down Expand Up @@ -45,6 +46,8 @@ USAGE
ip138 = true
elsif args.includes? "ipsb"
ipsb = true
else
STDERR.puts usage
end
end
end
Expand Down

0 comments on commit 0e5a773

Please sign in to comment.