trollop 1.7 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/History.txt +3 -0
  2. data/README.txt +79 -19
  3. data/Rakefile +9 -5
  4. data/lib/trollop.rb +7 -6
  5. metadata +12 -8
@@ -1,3 +1,6 @@
1
+ == 1.7.1 / 2008-01-07
2
+ * Documentation improvements
3
+
1
4
  == 1.7 / 2007-06-17
2
5
  * Fix incorrect error message for multiple missing required arguments
3
6
  (thanks to Neill Zero)
data/README.txt CHANGED
@@ -4,20 +4,21 @@ by William Morgan <wmorgan-trollop@masanjin.net>
4
4
 
5
5
  http://trollop.rubyforge.org
6
6
 
7
- == DESCRIPTION:
7
+ Documentation quickstart: See Trollop::Parser.
8
8
 
9
- Trollop is YAFCLAP --- yet another fine commandline argument
10
- processing library for Ruby. Trollop is designed to provide the
11
- maximal amount of GNU-style argument processing in the minimum number
12
- of lines of code (for you, the programmer).
9
+ == DESCRIPTION
13
10
 
14
- Trollop provides a nice automatically-generated help page, robust
15
- option parsing, and sensible defaults for everything you don't
16
- specify.
11
+ Trollop is YAFCLAP --- yet another fine commandline argument processor
12
+ for Ruby. Trollop is designed to provide the maximal amount of GNU-style
13
+ argument processing in the minimum number of lines of code (for you, the
14
+ programmer).
15
+
16
+ Trollop provides a nice automatically-generated help page, robust option
17
+ parsing, and sensible defaults for everything you don't specify.
17
18
 
18
19
  Trollop: getting you 90% of the way there with only 10% of the effort.
19
20
 
20
- == FEATURES/PROBLEMS:
21
+ == FEATURES/PROBLEMS
21
22
 
22
23
  - Simple usage.
23
24
  - Sensible defaults. No tweaking necessary, much tweaking possible.
@@ -26,20 +27,22 @@ Trollop: getting you 90% of the way there with only 10% of the effort.
26
27
  - Automatic help message generation, wrapped to current screen width.
27
28
  - Lots of unit tests.
28
29
 
29
- == SYNOPSIS:
30
+ == SYNOPSIS
30
31
 
31
32
  ###### simple ######
32
33
 
34
+ require 'trollop'
33
35
  opts = Trollop::options do
34
- opt :monkey, "Use monkey mode."
35
- opt :goat, "Use goat model", :default => true
36
+ opt :monkey, "Use monkey mode"
37
+ opt :goat, "Use goat mode", :default => true
36
38
  opt :num_limbs, "Set number of limbs", :default => 4
37
39
  end
38
40
 
39
41
  p opts
40
42
 
41
- ###### complex ######
43
+ ###### medium ######
42
44
 
45
+ require 'trollop'
43
46
  opts = Trollop::options do
44
47
  version "test 1.2.3 (c) 2007 William Morgan"
45
48
  banner <<-EOS
@@ -56,18 +59,75 @@ Trollop: getting you 90% of the way there with only 10% of the effort.
56
59
  opt :iters, "Number of iterations", :default => 5
57
60
  end
58
61
  Trollop::die :volume, "must be non-negative" if opts[:volume] < 0
59
- Trollop::die :file, "must exist" unless File.exists?(opts[:file]) if opts[:file]
62
+ Trollop::die :file, "must exist" unless File.exist?(opts[:file]) if opts[:file]
63
+
64
+ ###### real-life ######
65
+
66
+ require 'trollop'
67
+ opts = Trollop::options do
68
+ version "sup-sync (sup #{Redwood::VERSION})"
69
+ banner <<EOS
70
+ Synchronizes the Sup index with one or more message sources by adding
71
+ messages, deleting messages, or changing message state in the index as
72
+ appropriate.
73
+
74
+ [...]
75
+
76
+ Usage:
77
+ sup-sync [options] <source>*
78
+
79
+ where <source>* is zero or more source URIs. If no sources are given,
80
+ sync from all usual sources. Supported source URI schemes can be seen
81
+ by running "sup-add --help".
82
+
83
+ Options controlling WHICH messages sup-sync operates on:
84
+ EOS
85
+ opt :new, "Operate on new messages only. Don't scan over the entire source. (Default.)", :short => :none
86
+ opt :changed, "Scan over the entire source for messages that have been deleted, altered, or moved from another source. (In the case of mbox sources, this includes all messages AFTER an altered message.)"
87
+ opt :restored, "Operate only on those messages included in a dump file as specified by --restore which have changed state."
88
+ opt :all, "Operate on all messages in the source, regardless of newness or changedness."
89
+ opt :start_at, "For --changed and --all, start at a particular offset.", :type => :int
90
+
91
+ text <<EOS
92
+
93
+ Options controlling HOW message state is altered:
94
+ EOS
95
+ opt :asis, "If the message is already in the index, preserve its state. Otherwise, use default source state. (Default.)", :short => :none
96
+ opt :restore, "Restore message state from a dump file created with sup-dump. If a message is not in this dumpfile, act as --asis.", :type => String, :short => :none
97
+ opt :discard, "Discard any message state in the index and use the default source state. Dangerous!", :short => :none
98
+ opt :archive, "When using the default source state, mark messages as archived.", :short => "-x"
99
+ opt :read, "When using the default source state, mark messages as read."
100
+ opt :extra_labels, "When using the default source state, also apply these user-defined labels. Should be a comma-separated list.", :type => String, :short => :none
101
+
102
+ text <<EOS
103
+
104
+ Other options:
105
+ EOS
106
+ opt :verbose, "Print message ids as they're processed."
107
+ opt :optimize, "As the final operation, optimize the index."
108
+ opt :all_sources, "Scan over all sources.", :short => :none
109
+ opt :dry_run, "Don't actually modify the index. Probably only useful with --verbose.", :short => "-n"
110
+ opt :version, "Show version information", :short => :none
111
+
112
+ conflicts :changed, :all, :new, :restored
113
+ conflicts :asis, :restore, :discard
114
+ end
115
+ Trollop::die :restored, "requires --restore" if opts[:restored] unless opts[:restore]
116
+ if opts[:start_at]
117
+ Trollop::die :start_at, "must be non-negative" if opts[:start_at] < 0
118
+ Trollop::die :start_at, "requires either --changed or --all" unless opts[:changed] || opts[:all]
119
+ end
60
120
 
61
- == REQUIREMENTS:
121
+ == REQUIREMENTS
62
122
 
63
- * none
123
+ * none!
64
124
 
65
- == INSTALL:
125
+ == INSTALL
66
126
 
67
127
  * gem install trollop
68
128
 
69
- == LICENSE:
129
+ == LICENSE
70
130
 
71
- Copyright (c) 2007 William Morgan.
131
+ Copyright (c) 2008 William Morgan.
72
132
 
73
133
  Trollop is distributed under the same terms as Ruby.
data/Rakefile CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'hoe'
5
+
6
+ $:.unshift "lib"
5
7
  require 'trollop'
6
8
 
7
9
  class Hoe
@@ -11,7 +13,7 @@ end # thanks to "Mike H"
11
13
  Hoe.new('trollop', Trollop::VERSION) do |p|
12
14
  p.rubyforge_name = 'trollop'
13
15
  p.author = "William Morgan"
14
- p.summary = "YAFCLAP --- yet another fine commandline argument processing library for Ruby. Trollop is designed to provide the maximal amount of GNU-style argument processing in the minimum number of lines of code (for you, the programmer)."
16
+ p.summary = "Trollop is YAFCLAP --- yet another fine commandline argument processing library for Ruby. Trollop is designed to provide the maximal amount of GNU-style argument processing in the minimum number of lines of code (for you, the programmer)."
15
17
 
16
18
  p.description = p.paragraphs_of('README.txt', 4..5, 9..18).join("\n\n").gsub(/== SYNOPSIS/, "Synopsis")
17
19
  p.url = "http://trollop.rubyforge.org"
@@ -19,11 +21,13 @@ Hoe.new('trollop', Trollop::VERSION) do |p|
19
21
  p.email = "wmorgan-trollop@masanjin.net"
20
22
  end
21
23
 
22
- ## is there really no way to make a rule for this?
23
- WWW_FILES = %w(index.html README.txt FAQ.txt)
24
-
24
+ WWW_FILES = FileList["www/*"] + %w(README.txt FAQ.txt)
25
25
  task :upload_webpage => WWW_FILES do |t|
26
26
  sh "scp -C #{t.prerequisites * ' '} wmorgan@rubyforge.org:/var/www/gforge-projects/trollop/"
27
27
  end
28
28
 
29
- # vim: syntax=Ruby
29
+ task :upload_docs => [:docs] do |t|
30
+ sh "scp -Cr doc wmorgan@rubyforge.org:/var/www/gforge-projects/trollop/trollop"
31
+ end
32
+
33
+ # vim: syntax=ruby
@@ -5,7 +5,7 @@
5
5
 
6
6
  module Trollop
7
7
 
8
- VERSION = "1.7"
8
+ VERSION = "1.7.1"
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.
@@ -26,8 +26,9 @@ FLOAT_RE = /^-?((\d+(\.\d+)?)|(\.\d+))$/
26
26
  PARAM_RE = /^-(-|\.$|[^\d\.])/
27
27
 
28
28
  ## The commandline parser. In typical usage, the methods in this class
29
- ## will be handled internally by Trollop#options, in which case only
30
- ## the methods #opt, #banner and #version will be called.
29
+ ## will be handled internally by Trollop#options, in which case only the
30
+ ## methods #opt, #banner and #version, #depends, and #conflicts will
31
+ ## typically be called.
31
32
  class Parser
32
33
  ## The set of values specifiable as the :type parameter to #opt.
33
34
  TYPES = [:flag, :boolean, :bool, :int, :integer, :string, :double, :float]
@@ -171,9 +172,9 @@ class Parser
171
172
  def banner s; @order << [:text, s] end
172
173
  alias :text :banner
173
174
 
174
- ## Marks two (or more!) options as requiring each other. Only
175
- ## handles undirected dependcies. Directed dependencies are better
176
- ## modeled with #die.
175
+ ## Marks two (or more!) options as requiring each other. Only handles
176
+ ## undirected (i.e., mutual) dependencies. Directed dependencies are
177
+ ## better modeled with Trollop::die.
177
178
  def depends *syms
178
179
  syms.each { |sym| raise ArgumentError, "unknown option '#{sym}'" unless @specs[sym] }
179
180
  @constraints << [:depends, syms]
metadata CHANGED
@@ -3,15 +3,15 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: trollop
5
5
  version: !ruby/object:Gem::Version
6
- version: "1.7"
7
- date: 2007-06-17 00:00:00 -07:00
8
- summary: YAFCLAP --- yet another fine commandline argument processing library for Ruby. Trollop is designed to provide the maximal amount of GNU-style argument processing in the minimum number of lines of code (for you, the programmer).
6
+ version: 1.7.1
7
+ date: 2008-01-07 00:00:00 -08:00
8
+ summary: Trollop is YAFCLAP --- yet another fine commandline argument processing library for Ruby. Trollop is designed to provide the maximal amount of GNU-style argument processing in the minimum number of lines of code (for you, the programmer).
9
9
  require_paths:
10
10
  - lib
11
11
  email: wmorgan-trollop@masanjin.net
12
12
  homepage: http://trollop.rubyforge.org
13
13
  rubyforge_project: trollop
14
- description: "Trollop is YAFCLAP --- yet another fine commandline argument processing library for Ruby. Trollop is designed to provide the maximal amount of GNU-style argument processing in the minimum number of lines of code (for you, the programmer). Trollop provides a nice automatically-generated help page, robust option parsing, and sensible defaults for everything you don't specify. Synopsis: ###### simple ###### opts = Trollop::options do opt :monkey, \"Use monkey mode.\" opt :goat, \"Use goat model\", :default => true opt :num_limbs, \"Set number of limbs\", :default => 4 end p opts ###### complex ###### opts = Trollop::options do version \"test 1.2.3 (c) 2007 William Morgan\" banner <<-EOS Test is an awesome program that does something very, very important. Usage: test [options] <filenames>+ where [options] are: EOS opt :ignore, \"Ignore incorrect values\" opt :file, \"Extra data filename to read in, with a very long option description like this one\", :type => String opt :volume, \"Volume level\", :default => 3.0 opt :iters, \"Number of iterations\", :default => 5 end Trollop::die :volume, \"must be non-negative\" if opts[:volume] < 0 Trollop::die :file, \"must exist\" unless File.exists?(opts[:file]) if opts[:file] == REQUIREMENTS: * none"
14
+ description: "== DESCRIPTION Trollop is YAFCLAP --- yet another fine commandline argument processor for Ruby. Trollop is designed to provide the maximal amount of GNU-style argument processing in the minimum number of lines of code (for you, the programmer). - Simple usage. - Sensible defaults. No tweaking necessary, much tweaking possible. - Support for long options, short options, short option bundling, and automatic type validation and conversion. - Automatic help message generation, wrapped to current screen width. - Lots of unit tests. Synopsis ###### simple ###### require 'trollop' 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 p opts ###### medium ###### require 'trollop' opts = Trollop::options do version \"test 1.2.3 (c) 2007 William Morgan\" banner <<-EOS Test is an awesome program that does something very, very important. Usage: test [options] <filenames>+ where [options] are: EOS opt :ignore, \"Ignore incorrect values\" opt :file, \"Extra data filename to read in, with a very long option description like this one\", :type => String opt :volume, \"Volume level\", :default => 3.0 opt :iters, \"Number of iterations\", :default => 5 end Trollop::die :volume, \"must be non-negative\" if opts[:volume] < 0 Trollop::die :file, \"must exist\" unless File.exist?(opts[:file]) if opts[:file] ###### real-life ######"
15
15
  autorequire:
16
16
  default_executable:
17
17
  bindir: bin
@@ -38,10 +38,14 @@ files:
38
38
  - test/test_trollop.rb
39
39
  test_files:
40
40
  - test/test_trollop.rb
41
- rdoc_options: []
42
-
43
- extra_rdoc_files: []
44
-
41
+ rdoc_options:
42
+ - --main
43
+ - README.txt
44
+ extra_rdoc_files:
45
+ - FAQ.txt
46
+ - History.txt
47
+ - Manifest.txt
48
+ - README.txt
45
49
  executables: []
46
50
 
47
51
  extensions: []