Timeline for answer to Really Cheap Command-Line Option Parsing in Ruby by cjs
Current License: CC BY-SA 3.0
Post Revisions
13 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 12, 2021 at 18:22 | comment | added | Jose V |
you can do if for arg in ARGV; case arg; ...when.... ; end.empty?; handle-no-args-case; end;
|
|
| Mar 12, 2021 at 18:20 | comment | added | Jose V |
alternatively for arg in ARGV :)
|
|
| Jul 14, 2018 at 0:49 | comment | added | cjs | @overbyrd Precisely. In some situations you will be asking someone not just to copy a file to a dir and execute it, but copy two files to their machine and figure out how to get the second one into a place where the first will read it. You may never have seen a situation where that's not trivial; I have seen many. | |
| Jul 14, 2018 at 0:49 | comment | added | cjs |
@casey: It sounds like you left out the exit(2) line from usage().
|
|
| Jun 10, 2015 at 20:11 | comment | added | casey |
For me, I had to change when /^-/ then usage("Unknown option: #{ARGV[0].inspect}") to when /^-/ then usage("Unknown option: #{ARGV.shift.inspect}") or it would get into an infinite usage loop
|
|
| Jun 1, 2015 at 16:40 | comment | added | Overbryd |
Trollop does not need to be installed as a gem. You can simply drop one file it in you lib folder or code and use it without even touching rubygems.
|
|
| Feb 24, 2014 at 9:56 | comment | added | lzap | +1 Sometimes you need to reinvent the wheel, because you don't want or simply can't use other dependencies like Trollop. | |
| S Apr 11, 2013 at 21:13 | history | suggested | jtpereyda | CC BY-SA 3.0 |
Edited out deprecated syntax http://stackoverflow.com/questions/6964876/ruby-1-9-1-syntax-error
|
| Apr 11, 2013 at 20:51 | review | Suggested edits | |||
| S Apr 11, 2013 at 21:13 | |||||
| Dec 3, 2012 at 7:13 | comment | added | cjs | The premade wheel isn't smoother. Read the question again carefully, paying careful attention to the requirements. | |
| Nov 28, 2012 at 17:55 | comment | added | Mikey T.K. | Answers the question, but man, Trollop seems to be a lot easier to deal with. Why reinvent the wheel when the premade wheel is so much smoother? | |
| Aug 24, 2012 at 5:53 | vote | accept | cjs | ||
| Jun 19, 2009 at 10:47 | history | answered | cjs | CC BY-SA 2.5 |