File: FAQ.txt

package info (click to toggle)
libtrollop-ruby 1.9-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 104 kB
  • ctags: 85
  • sloc: ruby: 1,132; makefile: 7
file content (44 lines) | stat: -rw-r--r-- 1,703 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Trollop FAQ
-----------

Q: Why should I use Trollop?
A: Because it will take you FEWER LINES OF CODE to do reasonable option
   parsing than any other option parser in existence.

   Look:

     opts = Trollop::options do
       opt :monkey, "Use monkey mode"
       opt :goat, "Use goat mode", :default => true
       opt :num_limbs, "Set number of limbs", :default => 4
     end

   That's it. And opts is a hash and you do whatever you want with it.
   Trivial. You don't have to mix option processing code blocks with the
   declarations. You don't have to make a class for every option (what is
   this, Java?). You don't have to write more than 1 line of code per
   option.

Q: Why is it called "Trollop"?
A: No reason.

Q: Why does Trollop disallow numeric short argument names, like '-1'
   and '-9'?
A: Because it's ambiguous whether these are arguments or negative
   integer or floating-point parameters to arguments. E.g., what
   about "-f -3". Is that a negative three parameter to -f, or two
   separate parameters? 

   I could be very clever and detect when there are no arguments
   that require floating-point parameters, and allow such short option
   names in those cases, but opted for simplicity and consistency.

Q: Why does Trollop disallow options appearing multiple times, despite
   the POSIX standard allowing it?
A: Because basically I think it's confusing, and more often than
   not, a symptom of you making a mistake (e.g. getting lost in a long
   command line and accidentally setting the same thing twice.) 
   I also don't see that much advantage to "-vvvvv" over "-v 5", so
   Trollop will produce an error if you try to use the same argument
   multiple times.