drydock 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,16 @@
1
+ DRYDOCK, CHANGES
2
+
3
+ #### 0.3 (2009-02-05) ###############################
4
+
5
+ * Added support for custom Drydock::Commands objects
6
+ * Global and command-specific options are now available as
7
+ attributes of the Drydock::Commands class instance.
8
+ * Automatic execution
9
+ * Now in a single file (lib/drydock.rb)
10
+ * Started adding tests
11
+ * Improved documentation
12
+
13
+ #### 0.2 (2008-12-27) ###############################
14
+
15
+ * Initial release
16
+ * Forked from bmizerany/frylock
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2008 Delano Mandelbaum
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,70 @@
1
+ = Drydock - v0.3
2
+
3
+ Inspired by github-gem and bmizerany-frylock.
4
+
5
+ == Overview
6
+
7
+ Drydock is a seaworthy DSL for command line apps. It is contained in a single .rb which can be copied directly into your project.
8
+
9
+ == Install
10
+
11
+ One of:
12
+
13
+ * gem install drydock
14
+ * copy lib/drydock.rb into your lib directory.
15
+
16
+ Or for GitHub fans:
17
+
18
+ * git clone git://github.com/delano/drydock.git
19
+ * gem install delano-drydock
20
+
21
+ == Examples
22
+
23
+ See bin/example for more.
24
+
25
+ require 'rubygems'
26
+ require 'drydock'
27
+
28
+ default :welcome
29
+
30
+ before do
31
+ # You can execute a block before the requests command is executed. Instance
32
+ # variables defined here will be available to all commands.
33
+ end
34
+
35
+ command :welcome do
36
+ # Example: ruby bin/example
37
+
38
+ puts "Meatwad: Science is a mystery to man, isn't it Frylock?"
39
+ print "Frylock: At least we have some commands: "
40
+
41
+ # The commands method returns a hash of Frylock::Command objects
42
+ puts commands.keys.inject([]) { |list, command| list << command.to_s }.sort.join(', ')
43
+ end
44
+
45
+ option :f, :found, "A boolean value. Did you find the car?"
46
+ command :findcar do |options|
47
+ # +options+ is a hash containing the options defined above
48
+ # Example: ruby bin/example -f findcar
49
+
50
+ puts "Frylock: So, did they ever find your car?"
51
+
52
+ # The keys to the hash are the long string from the option definition.
53
+ # If only the short string is provided, those will be used instead (i.e. :f).
54
+ puts (!options[:found]) ? "Carl: No" :
55
+ "Carl: Oh, they found part of it, hangin' from a trestle near the turnpike."
56
+ end
57
+
58
+ == More Information
59
+
60
+ http://www.youtube.com/watch?v=m_wFEB4Oxlo
61
+
62
+ == Credits
63
+
64
+ * Delano Mandelbaum (delano@solutious.com)
65
+ * Bernie Kopell (bernie@solutious.com)
66
+
67
+
68
+ == License
69
+
70
+ See LICENSE.txt
@@ -0,0 +1,72 @@
1
+ require 'rubygems'
2
+ require 'rake/clean'
3
+ require 'rake/gempackagetask'
4
+ require 'hanna/rdoctask'
5
+ require 'fileutils'
6
+ include FileUtils
7
+
8
+ task :default => :test
9
+
10
+ # SPECS ===============================================================
11
+
12
+ desc 'Run specs with unit test style output'
13
+ task :test do |t|
14
+ sh "ruby tests/*_test.rb"
15
+ end
16
+
17
+ # PACKAGE =============================================================
18
+
19
+
20
+ require File.dirname(__FILE__) + "/lib/drydock"
21
+ load "drydock.gemspec"
22
+
23
+ version = Drydock::VERSION.to_s
24
+
25
+ Drydock.run = false
26
+
27
+ Rake::GemPackageTask.new(@spec) do |p|
28
+ p.need_tar = true if RUBY_PLATFORM !~ /mswin/
29
+ end
30
+
31
+ task :release => [ :rdoc, :package ]
32
+
33
+ task :install => [ :rdoc, :package ] do
34
+ sh %{sudo gem install pkg/#{name}-#{version}.gem}
35
+ end
36
+
37
+ task :uninstall => [ :clean ] do
38
+ sh %{sudo gem uninstall #{name}}
39
+ end
40
+
41
+
42
+ # Rubyforge Release / Publish Tasks ==================================
43
+
44
+ desc 'Publish website to rubyforge'
45
+ task 'publish:doc' => 'doc/index.html' do
46
+ sh 'scp -rp doc/* rubyforge.org:/var/www/gforge-projects/drydock/'
47
+ end
48
+
49
+ task 'publish:gem' => [:package] do |t|
50
+ sh <<-end
51
+ rubyforge add_release drydock drydock #{@spec.version} pkg/drydock-#{@spec.version}.gem &&
52
+ rubyforge add_file drydock drydock #{@spec.version} pkg/drydock-#{@spec.version}.tar.gz
53
+ end
54
+ end
55
+
56
+
57
+ Rake::RDocTask.new do |t|
58
+ t.rdoc_dir = 'doc'
59
+ t.title = "Drydock, A seaworthy DSL for command-line apps."
60
+ t.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
61
+ t.options << '--charset' << 'utf-8'
62
+ t.rdoc_files.include('LICENSE.txt')
63
+ t.rdoc_files.include('README.rdoc')
64
+ t.rdoc_files.include('CHANGES.txt')
65
+ t.rdoc_files.include('bin/*')
66
+ t.rdoc_files.include('lib/*.rb')
67
+ end
68
+
69
+ CLEAN.include [ 'pkg', '*.gem', '.config', 'doc' ]
70
+
71
+
72
+
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..')), 'lib'
4
+
5
+ require 'drydock'
6
+
7
+ default :welcome
8
+
9
+ before do
10
+ # You can execute a block before the requests command is executed. Instance
11
+ # variables defined here will be available to all commands.
12
+ end
13
+
14
+ after do
15
+ # And this will be called after the command.
16
+ end
17
+
18
+ command :welcome do
19
+ # Example: ruby bin/example
20
+
21
+ puts "Meatwad: Science is a mystery to man, isn't it Frylock?"
22
+ print "Frylock: At least we have some commands: "
23
+
24
+ # The commands method returns a hash of Drydock::Command objects
25
+ puts commands.keys.inject([]) { |list, command| list << command.to_s }.sort.join(', ')
26
+ end
27
+
28
+
29
+ option :f, :found, "A boolean value. Did you find the car?"
30
+ command :findcar do |obj|
31
+ # +obj+ is the Drylock::Command object instance. It contains accessors for all options.
32
+ # Example: ruby bin/example -f findcar
33
+
34
+ puts "Frylock: So, did they ever find your car?"
35
+
36
+ # The keys to the hash are the long string from the option definition.
37
+ # If only the short string is provided, those will be used instead (i.e. :f).
38
+ puts (!obj.found) ? "Carl: No" :
39
+ "Carl: Oh, they found part of it, hangin' from a trestle near the turnpike."
40
+ end
41
+
42
+
43
+
44
+ global_usage "USAGE: #{File.basename($0)} [global options] command [command options]"
45
+ global_option :s, :seconds, "Display values in seconds"
46
+ global_option :v, :verbose, "Verbosity level (i.e. -vvv is greater than -v)" do |v|
47
+ # Use instance variables to maintain values between option blocks.
48
+ # This will increment for every -v found (i.e. -vvv)
49
+ @val ||= 0
50
+ @val += 1
51
+ end
52
+
53
+
54
+ usage "#{$0} [-s] [-vv] date"
55
+ command :date do |obj, argv|
56
+ # +argv+ is an array containing the unnamed arguments
57
+ require 'time'
58
+ now = Time.now
59
+ puts "(Not verbose enough. Try adding a -v.)" if (obj.verbose || 0) == 1
60
+ puts "More verbosely, the date is now: " if (obj.verbose || 0) >= 2
61
+ puts (obj.seconds) ? now.to_i : now.to_s
62
+ end
63
+
64
+ usage "#{$0} rogue"
65
+ ignore :options
66
+ command :rogue do |obj, argv|
67
+ # You can use ignore :options to tell Drydock to not process the
68
+ # command-specific options.
69
+ if argv.empty?
70
+ puts "Had you supplied some arguments, I would have ignored them."
71
+ else
72
+ puts "Hi! You supplied some arguments but I ignored them."
73
+ puts "They're all still here in this array: %s" % argv.join(', ')
74
+ end
75
+ end
76
+
77
+ option :c, :check, "Check response codes for each URI"
78
+ option :d, :delim, String, "Output delimiter"
79
+ option :t, :timeout, Float, "Timeout value for HTTP request" do |v|
80
+ # You can provide an block to process the option value.
81
+ # This block must return the final value.
82
+ v = 10 if (v > 10)
83
+ v
84
+ end
85
+
86
+ usage 'echo "http://github.com/" | ruby bin/example process -c -d " " -t 15 http://solutious.com/'
87
+ command :processuri do |obj, argv, stdin|
88
+ # +cmd+ is the string used to evoke this command. Useful with alias_command (see below).
89
+ # +stdin+ is either an IO object or a custom object defined with a stdin block (see below)
90
+
91
+ require 'net/http'
92
+ require 'uri'
93
+ require 'timeout'
94
+
95
+ uris = [stdin, argv].flatten # Combine the argv and stdin arrays
96
+ delim = obj.delim || ','
97
+ timeout = obj.timeout || 5
98
+ code = :notchecked # The default code when :check is false
99
+
100
+ if uris.empty?
101
+ puts "Frylock: You didn't provide any URIs. "
102
+ puts "Master Shake: Ya, see #{$0} #{obj.alias} -h"
103
+ exit 0
104
+ end
105
+
106
+ uris.each_with_index do |uri, index|
107
+ code = response_code(uri, timeout) if (obj.check)
108
+ puts [index+1, uri, code].join(delim)
109
+ end
110
+ end
111
+ alias_command :checkuri, :processuri
112
+
113
+
114
+
115
+
116
+ stdin do |stdin, output|
117
+ # Pre-process STDIN for all commands. This example returns an array of lines.
118
+ # The command processuris uses this array.
119
+
120
+ # We only want piped data. If this is not included
121
+ # execution will wait for input from the user.
122
+ unless stdin.tty?
123
+
124
+ while !stdin.eof? do
125
+ line = stdin.readline
126
+ line.chomp!
127
+ (output ||= []) << line
128
+ end
129
+
130
+ end
131
+ output
132
+ end
133
+
134
+
135
+
136
+ # response_code
137
+ #
138
+ # return the HTTP response code for the given URI
139
+ # +uri+ A valid HTTP URI
140
+ # +duration+ The timeout threshold (in seconds) for the request.
141
+ def response_code(uri_str, duration=5)
142
+ response = :unavailable
143
+ begin
144
+ uri = (uri_str.kind_of? URI::HTTP) ? uri_str : URI.parse(uri_str)
145
+ timeout(duration) do
146
+ response = Net::HTTP.get_response(uri).code
147
+ end
148
+ rescue Exception => ex
149
+ end
150
+ response
151
+ end
152
+
@@ -0,0 +1,535 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+ <html lang='en'>
3
+ <head>
4
+ <title>Module: Drydock [Drydock, A seaworthy DSL for command-line apps.]</title>
5
+ <meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
6
+ <link href='.././rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
7
+ <script type='text/javascript'>
8
+ //<![CDATA[
9
+ function popupCode(url) {
10
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
11
+ }
12
+
13
+ function toggleCode(id) {
14
+ var code = document.getElementById(id)
15
+
16
+ code.style.display = code.style.display != 'block' ? 'block' : 'none'
17
+ return true
18
+ }
19
+
20
+ // Make codeblocks hidden by default
21
+ document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
22
+ //]]>
23
+ </script>
24
+ </head>
25
+ <body class='page'>
26
+ <div class='class' id='wrapper'>
27
+ <div class='header'>
28
+ <h1 class='name'>
29
+ <span class='type'>Module</span>
30
+ Drydock
31
+ </h1>
32
+ <ol class='paths'>
33
+ <li>
34
+ <a href="../files/lib/drydock_rb.html">lib/drydock.rb</a>
35
+ </li>
36
+ </ol>
37
+ </div>
38
+ <div id='content'>
39
+ <div id='text'>
40
+ <div id='description'>
41
+ <hr size="1"></hr><p>
42
+ <a href="Drydock.html">Drydock</a> is a DSL for command-line apps. See <a
43
+ href="../files/bin/example.html">bin/example</a> for usage examples.
44
+ </p>
45
+ </div>
46
+ <div id='method-list'>
47
+ <h2>Methods</h2>
48
+ <h3>public instance</h3>
49
+ <ol>
50
+ <li><a href="#M000007">after</a></li>
51
+ <li><a href="#M000015">alias_command</a></li>
52
+ <li><a href="#M000006">before</a></li>
53
+ <li><a href="#M000014">command</a></li>
54
+ <li><a href="#M000016">command_alias</a></li>
55
+ <li><a href="#M000017">commands</a></li>
56
+ <li><a href="#M000002">debug</a></li>
57
+ <li><a href="#M000003">debug?</a></li>
58
+ <li><a href="#M000004">default</a></li>
59
+ <li><a href="#M000010">get_current_option_parser</a></li>
60
+ <li><a href="#M000012">global_option</a></li>
61
+ <li><a href="#M000008">global_usage</a></li>
62
+ <li><a href="#M000020">has_run?</a></li>
63
+ <li><a href="#M000011">ignore</a></li>
64
+ <li><a href="#M000013">option</a></li>
65
+ <li><a href="#M000021">run!</a></li>
66
+ <li><a href="#M000019">run=</a></li>
67
+ <li><a href="#M000018">run?</a></li>
68
+ <li><a href="#M000005">stdin</a></li>
69
+ <li><a href="#M000009">usage</a></li>
70
+ </ol>
71
+ </div>
72
+ <div id='section'>
73
+ <div id='class-list'>
74
+ <h2>Classes and Modules</h2>
75
+ Class <a href="Drydock/Command.html" class="link">Drydock::Command</a><br />
76
+ Class <a href="Drydock/InvalidArgument.html" class="link">Drydock::InvalidArgument</a><br />
77
+ Class <a href="Drydock/MissingArgument.html" class="link">Drydock::MissingArgument</a><br />
78
+ Class <a href="Drydock/NoCommandsDefined.html" class="link">Drydock::NoCommandsDefined</a><br />
79
+ Class <a href="Drydock/UnknownCommand.html" class="link">Drydock::UnknownCommand</a><br />
80
+ </div>
81
+ <div id='constants-list'>
82
+ <h2>Constants</h2>
83
+ <div class='name-list'>
84
+ <table summary='Constants'>
85
+ <tr class='top-aligned-row context-row'>
86
+ <td class='context-item-name'>VERSION</td>
87
+ <td>=</td>
88
+ <td class='context-item-value'>0.3</td>
89
+ </tr>
90
+ </table>
91
+ </div>
92
+ </div>
93
+ <div id='methods'>
94
+ <h2>Public instance methods</h2>
95
+ <div class='public-instance method' id='method-M000007'>
96
+ <a name='M000007'> </a>
97
+ <div class='synopsis'>
98
+ <span class='name'>after</span>
99
+ <span class='arguments'>(&amp;b)</span>
100
+ </div>
101
+ <div class='description'>
102
+ <p>
103
+ Define a block to be called after the command. This is useful for stopping,
104
+ closing, etc... the stuff in the before block.
105
+ </p>
106
+ </div>
107
+ <div class='source'>
108
+ <a class='source-toggle' href='#' onclick="toggleCode('M000007-source'); return false">
109
+ [show source]
110
+ </a>
111
+ <pre id='M000007-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 165</span>&#x000A;165: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">after</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;166: <span class="ruby-ivar">@@after_block</span> = <span class="ruby-identifier">b</span>&#x000A;167: <span class="ruby-keyword kw">end</span></pre>
112
+ </div>
113
+ </div>
114
+ <div class='public-instance method' id='method-M000015'>
115
+ <a name='M000015'> </a>
116
+ <div class='synopsis'>
117
+ <span class='name'>alias_command</span>
118
+ <span class='arguments'>(aliaz, cmd)</span>
119
+ </div>
120
+ <div class='description'>
121
+ <p>
122
+ Used to create an alias to a defined command. Here&#8217;s an example:
123
+ </p>
124
+ <pre>command :task do; ...; end&#x000A;alias_command :pointer, :task</pre>
125
+ <p>
126
+ Either name can be used on the command-line:
127
+ </p>
128
+ <pre>$ script task [options]&#x000A;$ script pointer [options]</pre>
129
+ <p>
130
+ Inside of the command definition, you have access to the command name that
131
+ was used via obj.alias.
132
+ </p>
133
+ </div>
134
+ <div class='source'>
135
+ <a class='source-toggle' href='#' onclick="toggleCode('M000015-source'); return false">
136
+ [show source]
137
+ </a>
138
+ <pre id='M000015-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 274</span>&#x000A;274: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">alias_command</span>(<span class="ruby-identifier">aliaz</span>, <span class="ruby-identifier">cmd</span>)&#x000A;275: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">commands</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-identifier">cmd</span>&#x000A;276: <span class="ruby-ivar">@@commands</span>[<span class="ruby-identifier">aliaz</span>] = <span class="ruby-identifier">commands</span>[<span class="ruby-identifier">cmd</span>]&#x000A;277: <span class="ruby-keyword kw">end</span></pre>
139
+ </div>
140
+ </div>
141
+ <div class='public-instance method' id='method-M000006'>
142
+ <a name='M000006'> </a>
143
+ <div class='synopsis'>
144
+ <span class='name'>before</span>
145
+ <span class='arguments'>(&amp;b)</span>
146
+ </div>
147
+ <div class='description'>
148
+ <p>
149
+ Define a block to be called before the command. This is useful for opening
150
+ database connections, etc...
151
+ </p>
152
+ </div>
153
+ <div class='source'>
154
+ <a class='source-toggle' href='#' onclick="toggleCode('M000006-source'); return false">
155
+ [show source]
156
+ </a>
157
+ <pre id='M000006-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 159</span>&#x000A;159: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">before</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;160: <span class="ruby-ivar">@@before_block</span> = <span class="ruby-identifier">b</span>&#x000A;161: <span class="ruby-keyword kw">end</span></pre>
158
+ </div>
159
+ </div>
160
+ <div class='public-instance method' id='method-M000014'>
161
+ <a name='M000014'> </a>
162
+ <div class='synopsis'>
163
+ <span class='name'>command</span>
164
+ <span class='arguments'>(*cmds, &amp;b)</span>
165
+ </div>
166
+ <div class='description'>
167
+ <p>
168
+ Define a command.
169
+ </p>
170
+ <pre>command :task do&#x000A; ...&#x000A;end</pre>
171
+ <p>
172
+ A custom command class can be specified using Hash syntax. The class must
173
+ inherit from <a href="Drydock/Command.html">Drydock::Command</a> (class
174
+ CustomeClass < <a href="Drydock/Command.html">Drydock::Command</a>)
175
+ </p>
176
+ <pre>command :task =&gt; CustomCommand do&#x000A; ...&#x000A;end</pre>
177
+ </div>
178
+ <div class='source'>
179
+ <a class='source-toggle' href='#' onclick="toggleCode('M000014-source'); return false">
180
+ [show source]
181
+ </a>
182
+ <pre id='M000014-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 244</span>&#x000A;244: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">command</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">cmds</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;245: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>&#x000A;246: <span class="ruby-ivar">@@command_opts_parser</span> <span class="ruby-operator">||=</span> []&#x000A;247: <span class="ruby-ivar">@@command_option_names</span> <span class="ruby-operator">||=</span> []&#x000A;248: <span class="ruby-identifier">cmds</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cmd</span><span class="ruby-operator">|</span> &#x000A;249: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cmd</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>&#x000A;250: <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cmd</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">cmd</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">first</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;251: <span class="ruby-keyword kw">else</span>&#x000A;252: <span class="ruby-identifier">c</span> = <span class="ruby-constant">Drydock</span><span class="ruby-operator">::</span><span class="ruby-constant">Command</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;253: <span class="ruby-keyword kw">end</span>&#x000A;254: <span class="ruby-identifier">commands</span>[<span class="ruby-identifier">c</span>.<span class="ruby-identifier">cmd</span>] = <span class="ruby-identifier">c</span>&#x000A;255: <span class="ruby-identifier">command_index_map</span>[<span class="ruby-identifier">c</span>.<span class="ruby-identifier">cmd</span>] = <span class="ruby-ivar">@@command_index</span>&#x000A;256: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>&#x000A;257: <span class="ruby-keyword kw">end</span>&#x000A;258: &#x000A;259: <span class="ruby-keyword kw">end</span></pre>
183
+ </div>
184
+ </div>
185
+ <div class='public-instance method' id='method-M000016'>
186
+ <a name='M000016'> </a>
187
+ <div class='synopsis'>
188
+ <span class='name'>command_alias</span>
189
+ <span class='arguments'>(aliaz, cmd)</span>
190
+ </div>
191
+ <div class='description'>
192
+ <p>
193
+ Alias for <a href="Drydock.html#M000015">alias_command</a>
194
+ </p>
195
+ </div>
196
+ </div>
197
+ <div class='public-instance method' id='method-M000017'>
198
+ <a name='M000017'> </a>
199
+ <div class='synopsis'>
200
+ <span class='name'>commands</span>
201
+ <span class='arguments'>()</span>
202
+ </div>
203
+ <div class='description'>
204
+ <p>
205
+ An array of the currently defined <a
206
+ href="Drydock/Command.html">Drydock::Command</a> objects
207
+ </p>
208
+ </div>
209
+ <div class='source'>
210
+ <a class='source-toggle' href='#' onclick="toggleCode('M000017-source'); return false">
211
+ [show source]
212
+ </a>
213
+ <pre id='M000017-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 281</span>&#x000A;281: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">commands</span>&#x000A;282: <span class="ruby-ivar">@@commands</span> <span class="ruby-operator">||=</span> {}&#x000A;283: <span class="ruby-keyword kw">end</span></pre>
214
+ </div>
215
+ </div>
216
+ <div class='public-instance method' id='method-M000002'>
217
+ <a name='M000002'> </a>
218
+ <div class='synopsis'>
219
+ <span class='name'>debug</span>
220
+ <span class='arguments'>(toggle=false)</span>
221
+ </div>
222
+ <div class='description'>
223
+ <p>
224
+ Enable or disable debug output.
225
+ </p>
226
+ <pre>debug :on&#x000A;debug :off</pre>
227
+ <p>
228
+ Calling without :on or :off will toggle the value.
229
+ </p>
230
+ </div>
231
+ <div class='source'>
232
+ <a class='source-toggle' href='#' onclick="toggleCode('M000002-source'); return false">
233
+ [show source]
234
+ </a>
235
+ <pre id='M000002-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 126</span>&#x000A;126: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">debug</span>(<span class="ruby-identifier">toggle</span>=<span class="ruby-keyword kw">false</span>)&#x000A;127: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">toggle</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Symbol</span>&#x000A;128: <span class="ruby-ivar">@@debug</span> = <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">toggle</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:on</span>&#x000A;129: <span class="ruby-ivar">@@debug</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">toggle</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:off</span>&#x000A;130: <span class="ruby-keyword kw">else</span>&#x000A;131: <span class="ruby-ivar">@@debug</span> = (<span class="ruby-operator">!</span><span class="ruby-ivar">@@debug</span>)&#x000A;132: <span class="ruby-keyword kw">end</span>&#x000A;133: <span class="ruby-keyword kw">end</span></pre>
236
+ </div>
237
+ </div>
238
+ <div class='public-instance method' id='method-M000003'>
239
+ <a name='M000003'> </a>
240
+ <div class='synopsis'>
241
+ <span class='name'>debug?</span>
242
+ <span class='arguments'>()</span>
243
+ </div>
244
+ <div class='description'>
245
+ <p>
246
+ Returns true if debug output is enabled.
247
+ </p>
248
+ </div>
249
+ <div class='source'>
250
+ <a class='source-toggle' href='#' onclick="toggleCode('M000003-source'); return false">
251
+ [show source]
252
+ </a>
253
+ <pre id='M000003-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 135</span>&#x000A;135: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">debug?</span>&#x000A;136: <span class="ruby-ivar">@@debug</span>&#x000A;137: <span class="ruby-keyword kw">end</span></pre>
254
+ </div>
255
+ </div>
256
+ <div class='public-instance method' id='method-M000004'>
257
+ <a name='M000004'> </a>
258
+ <div class='synopsis'>
259
+ <span class='name'>default</span>
260
+ <span class='arguments'>(cmd)</span>
261
+ </div>
262
+ <div class='description'>
263
+ <p>
264
+ Define a default command.
265
+ </p>
266
+ <pre>default :task</pre>
267
+ </div>
268
+ <div class='source'>
269
+ <a class='source-toggle' href='#' onclick="toggleCode('M000004-source'); return false">
270
+ [show source]
271
+ </a>
272
+ <pre id='M000004-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 143</span>&#x000A;143: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">default</span>(<span class="ruby-identifier">cmd</span>)&#x000A;144: <span class="ruby-ivar">@@default_command</span> = <span class="ruby-identifier">canonize</span>(<span class="ruby-identifier">cmd</span>)&#x000A;145: <span class="ruby-keyword kw">end</span></pre>
273
+ </div>
274
+ </div>
275
+ <div class='public-instance method' id='method-M000010'>
276
+ <a name='M000010'> </a>
277
+ <div class='synopsis'>
278
+ <span class='name'>get_current_option_parser</span>
279
+ <span class='arguments'>()</span>
280
+ </div>
281
+ <div class='description'>
282
+ <p>
283
+ Grab the options parser for the current command or create it if it
284
+ doesn&#8217;t exist.
285
+ </p>
286
+ </div>
287
+ <div class='source'>
288
+ <a class='source-toggle' href='#' onclick="toggleCode('M000010-source'); return false">
289
+ [show source]
290
+ </a>
291
+ <pre id='M000010-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 183</span>&#x000A;183: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_current_option_parser</span>&#x000A;184: <span class="ruby-ivar">@@command_opts_parser</span> <span class="ruby-operator">||=</span> []&#x000A;185: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>&#x000A;186: (<span class="ruby-ivar">@@command_opts_parser</span>[<span class="ruby-ivar">@@command_index</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span>)&#x000A;187: <span class="ruby-keyword kw">end</span></pre>
292
+ </div>
293
+ </div>
294
+ <div class='public-instance method' id='method-M000012'>
295
+ <a name='M000012'> </a>
296
+ <div class='synopsis'>
297
+ <span class='name'>global_option</span>
298
+ <span class='arguments'>(*args, &amp;b)</span>
299
+ </div>
300
+ <div class='description'>
301
+ <p>
302
+ Define a global option. See <tt>option</tt> for more info.
303
+ </p>
304
+ </div>
305
+ <div class='source'>
306
+ <a class='source-toggle' href='#' onclick="toggleCode('M000012-source'); return false">
307
+ [show source]
308
+ </a>
309
+ <pre id='M000012-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 202</span>&#x000A;202: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">global_option</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;203: <span class="ruby-identifier">args</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">global_opts_parser</span>)&#x000A;204: <span class="ruby-identifier">global_option_names</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">option_parser</span>(<span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;205: <span class="ruby-keyword kw">end</span></pre>
310
+ </div>
311
+ </div>
312
+ <div class='public-instance method' id='method-M000008'>
313
+ <a name='M000008'> </a>
314
+ <div class='synopsis'>
315
+ <span class='name'>global_usage</span>
316
+ <span class='arguments'>(msg)</span>
317
+ </div>
318
+ <div class='description'>
319
+ <p>
320
+ Define the default global usage banner. This is displayed with
321
+ &#8220;script -h&#8221;.
322
+ </p>
323
+ </div>
324
+ <div class='source'>
325
+ <a class='source-toggle' href='#' onclick="toggleCode('M000008-source'); return false">
326
+ [show source]
327
+ </a>
328
+ <pre id='M000008-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 171</span>&#x000A;171: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">global_usage</span>(<span class="ruby-identifier">msg</span>)&#x000A;172: <span class="ruby-ivar">@@global_options</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">OpenStruct</span>.<span class="ruby-identifier">new</span>&#x000A;173: <span class="ruby-identifier">global_opts_parser</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">&quot;USAGE: #{msg}&quot;</span>&#x000A;174: <span class="ruby-keyword kw">end</span></pre>
329
+ </div>
330
+ </div>
331
+ <div class='public-instance method' id='method-M000020'>
332
+ <a name='M000020'> </a>
333
+ <div class='synopsis'>
334
+ <span class='name'>has_run?</span>
335
+ <span class='arguments'>()</span>
336
+ </div>
337
+ <div class='description'>
338
+ <p>
339
+ Return true if a command has been executed.
340
+ </p>
341
+ </div>
342
+ <div class='source'>
343
+ <a class='source-toggle' href='#' onclick="toggleCode('M000020-source'); return false">
344
+ [show source]
345
+ </a>
346
+ <pre id='M000020-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 298</span>&#x000A;298: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_run?</span>&#x000A;299: <span class="ruby-ivar">@@has_run</span>&#x000A;300: <span class="ruby-keyword kw">end</span></pre>
347
+ </div>
348
+ </div>
349
+ <div class='public-instance method' id='method-M000011'>
350
+ <a name='M000011'> </a>
351
+ <div class='synopsis'>
352
+ <span class='name'>ignore</span>
353
+ <span class='arguments'>(what=:nothing)</span>
354
+ </div>
355
+ <div class='description'>
356
+ <p>
357
+ Tell the <a href="Drydock.html">Drydock</a> parser to ignore something. <a
358
+ href="Drydock.html">Drydock</a> will currently only listen to you if you
359
+ tell it to &#8220;ignore :options&#8221;, otherwise it will ignore you!
360
+ </p>
361
+ <p>
362
+ <tt>what</tt> the thing to ignore. When it equals :options <a
363
+ href="Drydock.html">Drydock</a> will not parse the command-specific
364
+ arguments. It will pass the <a href="Drydock/Command.html">Command</a>
365
+ object the list of arguments. This is useful when you want to parse the
366
+ arguments in some a way that&#8217;s too crazy, dangerous for <a
367
+ href="Drydock.html">Drydock</a> to handle automatically.
368
+ </p>
369
+ </div>
370
+ <div class='source'>
371
+ <a class='source-toggle' href='#' onclick="toggleCode('M000011-source'); return false">
372
+ [show source]
373
+ </a>
374
+ <pre id='M000011-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 197</span>&#x000A;197: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ignore</span>(<span class="ruby-identifier">what</span>=<span class="ruby-identifier">:nothing</span>)&#x000A;198: <span class="ruby-ivar">@@command_opts_parser</span>[<span class="ruby-ivar">@@command_index</span>] = <span class="ruby-identifier">:ignore</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">what</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:options</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">what</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:all</span>&#x000A;199: <span class="ruby-keyword kw">end</span></pre>
375
+ </div>
376
+ </div>
377
+ <div class='public-instance method' id='method-M000013'>
378
+ <a name='M000013'> </a>
379
+ <div class='synopsis'>
380
+ <span class='name'>option</span>
381
+ <span class='arguments'>(*args, &amp;b)</span>
382
+ </div>
383
+ <div class='description'>
384
+ <p>
385
+ Define a command-specific option.
386
+ </p>
387
+ <p>
388
+ <tt>args</tt> is passed directly to OptionParser.on so it can contain
389
+ anything that&#8217;s valid to that method. Some examples: [:h, :help,
390
+ &#8220;Displays this message&#8221;] [:m, :max, Integer, &#8220;Maximum
391
+ threshold&#8221;] [&#8217;-l x,y,z&#8217;, &#8217;&#8212;lang=x,y,z&#8217;,
392
+ Array, &#8220;Requested languages&#8221;] If a class is included, it will
393
+ tell OptionParser to expect a value otherwise it assumes a boolean value.
394
+ </p>
395
+ <p>
396
+ All calls to <tt>option</tt> must come before the command they&#8217;re
397
+ associated to. Example:
398
+ </p>
399
+ <pre>option :l, :longname, String, &quot;Description&quot; do; ...; end&#x000A;command :task do |obj|; ...; end</pre>
400
+ <p>
401
+ When calling your script with a specific command-line option, the value is
402
+ available via obj.longname inside the command block.
403
+ </p>
404
+ </div>
405
+ <div class='source'>
406
+ <a class='source-toggle' href='#' onclick="toggleCode('M000013-source'); return false">
407
+ [show source]
408
+ </a>
409
+ <pre id='M000013-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 226</span>&#x000A;226: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">option</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;227: <span class="ruby-identifier">args</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">get_current_option_parser</span>)&#x000A;228: <span class="ruby-identifier">current_command_option_names</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">option_parser</span>(<span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;229: <span class="ruby-keyword kw">end</span></pre>
410
+ </div>
411
+ </div>
412
+ <div class='public-instance method' id='method-M000021'>
413
+ <a name='M000021'> </a>
414
+ <div class='synopsis'>
415
+ <span class='name'>run!</span>
416
+ <span class='arguments'>(argv=[], stdin=STDIN)</span>
417
+ </div>
418
+ <div class='description'>
419
+ <p>
420
+ Execute the given command. By default, <a href="Drydock.html">Drydock</a>
421
+ automatically executes itself and provides handlers for known errors. You
422
+ can override this functionality by calling <tt><a
423
+ href="Drydock.html#M000021">Drydock.run!</a></tt> yourself. <a
424
+ href="Drydock.html">Drydock</a> will only call <tt>run!</tt> once.
425
+ </p>
426
+ </div>
427
+ <div class='source'>
428
+ <a class='source-toggle' href='#' onclick="toggleCode('M000021-source'); return false">
429
+ [show source]
430
+ </a>
431
+ <pre id='M000021-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 306</span>&#x000A;306: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run!</span>(<span class="ruby-identifier">argv</span>=[], <span class="ruby-identifier">stdin</span>=<span class="ruby-constant">STDIN</span>)&#x000A;307: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">has_run?</span>&#x000A;308: <span class="ruby-ivar">@@has_run</span> = <span class="ruby-keyword kw">true</span>&#x000A;309: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NoCommandsDefined</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">commands</span>&#x000A;310: <span class="ruby-ivar">@@global_options</span>, <span class="ruby-identifier">cmd_name</span>, <span class="ruby-ivar">@@command_options</span>, <span class="ruby-identifier">argv</span> = <span class="ruby-identifier">process_arguments</span>(<span class="ruby-identifier">argv</span>)&#x000A;311: &#x000A;312: <span class="ruby-identifier">cmd_name</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">default_command</span>&#x000A;313: &#x000A;314: <span class="ruby-identifier">raise</span> <span class="ruby-constant">UnknownCommand</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">cmd_name</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command?</span>(<span class="ruby-identifier">cmd_name</span>)&#x000A;315: &#x000A;316: <span class="ruby-identifier">stdin</span> = (<span class="ruby-keyword kw">defined?</span> <span class="ruby-ivar">@@stdin_block</span>) <span class="ruby-operator">?</span> <span class="ruby-ivar">@@stdin_block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">stdin</span>, []) <span class="ruby-operator">:</span> <span class="ruby-identifier">stdin</span>&#x000A;317: <span class="ruby-ivar">@@before_block</span>.<span class="ruby-identifier">call</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">defined?</span> <span class="ruby-ivar">@@before_block</span>&#x000A;318: &#x000A;319: <span class="ruby-identifier">call_command</span>(<span class="ruby-identifier">cmd_name</span>, <span class="ruby-identifier">argv</span>, <span class="ruby-identifier">stdin</span>)&#x000A;320: &#x000A;321: <span class="ruby-ivar">@@after_block</span>.<span class="ruby-identifier">call</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">defined?</span> <span class="ruby-ivar">@@after_block</span>&#x000A;322: &#x000A;323: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidOption</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>&#x000A;324: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Drydock</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidArgument</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ex</span>.<span class="ruby-identifier">args</span>)&#x000A;325: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">MissingArgument</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>&#x000A;326: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Drydock</span><span class="ruby-operator">::</span><span class="ruby-constant">MissingArgument</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ex</span>.<span class="ruby-identifier">args</span>)&#x000A;327: <span class="ruby-keyword kw">end</span></pre>
432
+ </div>
433
+ </div>
434
+ <div class='public-instance method' id='method-M000019'>
435
+ <a name='M000019'> </a>
436
+ <div class='synopsis'>
437
+ <span class='name'>run=</span>
438
+ <span class='arguments'>(v)</span>
439
+ </div>
440
+ <div class='description'>
441
+ <p>
442
+ Disable automatic execution (enabled by default)
443
+ </p>
444
+ <pre>Drydock.run = false</pre>
445
+ </div>
446
+ <div class='source'>
447
+ <a class='source-toggle' href='#' onclick="toggleCode('M000019-source'); return false">
448
+ [show source]
449
+ </a>
450
+ <pre id='M000019-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 293</span>&#x000A;293: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run=</span>(<span class="ruby-identifier">v</span>)&#x000A;294: <span class="ruby-ivar">@@run</span> = (<span class="ruby-identifier">v</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span> &#x000A;295: <span class="ruby-keyword kw">end</span></pre>
451
+ </div>
452
+ </div>
453
+ <div class='public-instance method' id='method-M000018'>
454
+ <a name='M000018'> </a>
455
+ <div class='synopsis'>
456
+ <span class='name'>run?</span>
457
+ <span class='arguments'>()</span>
458
+ </div>
459
+ <div class='description'>
460
+ <p>
461
+ Returns true if automatic execution is enabled.
462
+ </p>
463
+ </div>
464
+ <div class='source'>
465
+ <a class='source-toggle' href='#' onclick="toggleCode('M000018-source'); return false">
466
+ [show source]
467
+ </a>
468
+ <pre id='M000018-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 286</span>&#x000A;286: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run?</span>&#x000A;287: <span class="ruby-ivar">@@run</span>&#x000A;288: <span class="ruby-keyword kw">end</span></pre>
469
+ </div>
470
+ </div>
471
+ <div class='public-instance method' id='method-M000005'>
472
+ <a name='M000005'> </a>
473
+ <div class='synopsis'>
474
+ <span class='name'>stdin</span>
475
+ <span class='arguments'>(&amp;b)</span>
476
+ </div>
477
+ <div class='description'>
478
+ <p>
479
+ Define a block for processing STDIN before the command is called. The
480
+ command block receives the return value of this block in a named argument:
481
+ </p>
482
+ <pre>command :task do |obj, argv, stdin|; ...; end</pre>
483
+ <p>
484
+ If a stdin block isn&#8217;t defined, <tt>stdin</tt> above will be the
485
+ STDIN IO handle.
486
+ </p>
487
+ </div>
488
+ <div class='source'>
489
+ <a class='source-toggle' href='#' onclick="toggleCode('M000005-source'); return false">
490
+ [show source]
491
+ </a>
492
+ <pre id='M000005-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 153</span>&#x000A;153: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stdin</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;154: <span class="ruby-ivar">@@stdin_block</span> = <span class="ruby-identifier">b</span>&#x000A;155: <span class="ruby-keyword kw">end</span></pre>
493
+ </div>
494
+ </div>
495
+ <div class='public-instance method' id='method-M000009'>
496
+ <a name='M000009'> </a>
497
+ <div class='synopsis'>
498
+ <span class='name'>usage</span>
499
+ <span class='arguments'>(msg)</span>
500
+ </div>
501
+ <div class='description'>
502
+ <p>
503
+ Define a command-specific usage banner. This is displayed with
504
+ &#8220;script command -h&#8220;
505
+ </p>
506
+ </div>
507
+ <div class='source'>
508
+ <a class='source-toggle' href='#' onclick="toggleCode('M000009-source'); return false">
509
+ [show source]
510
+ </a>
511
+ <pre id='M000009-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 178</span>&#x000A;178: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">usage</span>(<span class="ruby-identifier">msg</span>)&#x000A;179: <span class="ruby-identifier">get_current_option_parser</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">&quot;USAGE: #{msg}&quot;</span>&#x000A;180: <span class="ruby-keyword kw">end</span></pre>
512
+ </div>
513
+ </div>
514
+ </div>
515
+ </div>
516
+ </div>
517
+ </div>
518
+ <div id='footer-push'></div>
519
+ </div>
520
+ <div id='footer'>
521
+ <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
522
+ <script type='text/javascript'>
523
+ //<![CDATA[
524
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
525
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/scr
526
+
527
+ try {
528
+ var pageTracker = _gat._getTracker("UA-4642735-10");
529
+ pageTracker._trackPageview();
530
+ } catch(err) {}
531
+ //]]>
532
+ </script>
533
+ </div>
534
+ </body>
535
+ </html>