-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #150 from nanobowers/didyoumean
adding support for DidYouMean when long options are spelled incorrectly
- Loading branch information
Showing
3 changed files
with
124 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env ruby | ||
require_relative '../lib/optimist' | ||
|
||
opts = Optimist::options do | ||
opt :cone, "Ice cream cone" | ||
opt :zippy, "It zips" | ||
opt :zapzy, "It zapz" | ||
opt :big_bug, "Madagascar cockroach" | ||
end | ||
p opts | ||
|
||
# $ ./didyoumean.rb --one | ||
# Error: unknown argument '--one'. Did you mean: [--cone] ?. | ||
# Try --help for help. | ||
|
||
# $ ./didyoumean.rb --zappy | ||
# Error: unknown argument '--zappy'. Did you mean: [--zapzy, --zippy] ?. | ||
# Try --help for help. | ||
|
||
# $ ./didyoumean.rb --big_bug | ||
# Error: unknown argument '--big_bug'. Did you mean: [--big-bug] ?. | ||
# Try --help for help. | ||
|
||
# $ ./didyoumean.rb --bigbug | ||
# Error: unknown argument '--bigbug'. Did you mean: [--big-bug] ?. | ||
# Try --help for help. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters