trollop 1.10.2 → 1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/README.txt +4 -2
- data/Rakefile +2 -2
- data/lib/trollop.rb +14 -2
- metadata +3 -3
data/History.txt
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== 1.11 / 2009-01-29
|
2
|
+
* Set <opt>_given keys in the results hash for options that were specified
|
3
|
+
on the commandline.
|
4
|
+
|
1
5
|
== 1.10.2 / 2008-10-23
|
2
6
|
* No longer try `stty size` for screen size detection. Just use curses, and
|
3
7
|
screen users will have to deal with the screen clearing.
|
data/README.txt
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
== trollop
|
2
2
|
|
3
|
-
by William Morgan
|
3
|
+
by William Morgan (wmorgan-trollop at the masanjin dot nets or http://cs.stanford.edu/~ruby)
|
4
4
|
|
5
|
-
http://trollop.rubyforge.org
|
5
|
+
Main page: http://trollop.rubyforge.org
|
6
|
+
|
7
|
+
Release announcements and comments: http://all-thing.net/search/label/trollop
|
6
8
|
|
7
9
|
Documentation quickstart: See Trollop::options and Trollop::Parser#opt.
|
8
10
|
|
data/Rakefile
CHANGED
@@ -26,10 +26,10 @@ task :upload_webpage => WWW_FILES do |t|
|
|
26
26
|
end
|
27
27
|
|
28
28
|
task :rdoc do |t|
|
29
|
-
sh "rdoc lib README.txt History.txt"
|
29
|
+
sh "rdoc lib README.txt History.txt -m README.txt"
|
30
30
|
end
|
31
31
|
|
32
|
-
task :upload_docs =>
|
32
|
+
task :upload_docs => :rdoc do |t|
|
33
33
|
sh "rsync -az -essh doc/* wmorgan@rubyforge.org:/var/www/gforge-projects/trollop/trollop/"
|
34
34
|
end
|
35
35
|
|
data/lib/trollop.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
module Trollop
|
7
7
|
|
8
|
-
VERSION = "1.
|
8
|
+
VERSION = "1.11"
|
9
9
|
|
10
10
|
## Thrown by Parser in the event of a commandline error. Not needed if
|
11
11
|
## you're using the Trollop::options entry.
|
@@ -431,6 +431,8 @@ class Parser
|
|
431
431
|
opts = @specs[sym]
|
432
432
|
raise CommandlineError, "option '#{arg}' needs a parameter" if params.empty? && opts[:type] != :flag
|
433
433
|
|
434
|
+
vals["#{sym}_given".intern] = true # mark argument as specified on the commandline
|
435
|
+
|
434
436
|
case opts[:type]
|
435
437
|
when :flag
|
436
438
|
vals[sym] = !opts[:default]
|
@@ -628,6 +630,12 @@ end
|
|
628
630
|
## (Parser#opt), zero or more calls to +text+ (Parser#text), and
|
629
631
|
## probably a call to +version+ (Parser#version).
|
630
632
|
##
|
633
|
+
## The returned block contains a value for every option specified with
|
634
|
+
## +opt+. The value will be the value given on the commandline, or the
|
635
|
+
## default value if the option was not specified on the commandline. For
|
636
|
+
## every option specified on the commandline, a key "<option
|
637
|
+
## name>_given" will also be set in the hash.
|
638
|
+
##
|
631
639
|
## Example:
|
632
640
|
##
|
633
641
|
## require 'trollop'
|
@@ -638,7 +646,11 @@ end
|
|
638
646
|
## opt :num_thumbs, "Number of thumbs", :type => :int # an integer --num-thumbs <i>, defaulting to nil
|
639
647
|
## end
|
640
648
|
##
|
641
|
-
##
|
649
|
+
## ## if called with no arguments
|
650
|
+
## p opts # => { :monkey => false, :goat => true, :num_limbs => 4, :num_thumbs => nil }
|
651
|
+
##
|
652
|
+
## ## if called with --monkey
|
653
|
+
## p opts # => {:monkey_given=>true, :monkey=>true, :goat=>true, :num_limbs=>4, :help=>false, :num_thumbs=>nil}
|
642
654
|
##
|
643
655
|
## See more examples at http://trollop.rubyforge.org.
|
644
656
|
def options args = ARGV, *a, &b
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trollop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: "1.11"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Morgan
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-01-29 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
16
|
+
description: "Documentation quickstart: See Trollop::options and Trollop::Parser#opt. == DESCRIPTION == REQUIREMENTS * A burning desire to write less code. == INSTALL * gem install trollop == LICENSE Copyright (c) 2008 William Morgan. Trollop is distributed under the same terms as Ruby."
|
17
17
|
email: wmorgan-trollop@masanjin.net
|
18
18
|
executables: []
|
19
19
|
|