Clean up usage information for commands.

This commit is contained in:
Conrad Irwin 2011-09-10 13:22:47 -07:00
parent ca5d6b34f1
commit f1b3dfbf18
3 changed files with 55 additions and 33 deletions

View File

@ -11,9 +11,11 @@ class Pry
target = target() target = target()
opts = Slop.parse!(args) do |opt| opts = Slop.parse!(args) do |opt|
opt.banner = "Usage: show-doc [OPTIONS] [METH 1] [METH 2] [METH N]\n" \ opt.banner unindent <<-USAGE
"Show the comments above method METH. Tries instance methods first and then methods by default.\n" \ Usage: show-doc [OPTIONS] [METH 1] [METH 2] [METH N]
"e.g show-doc hello_method" Show the comments above method METH. Tries instance methods first and then methods by default.
e.g show-doc hello_method
USAGE
opt.on :M, "instance-methods", "Operate on instance methods." opt.on :M, "instance-methods", "Operate on instance methods."
opt.on :m, :methods, "Operate on methods." opt.on :m, :methods, "Operate on methods."
@ -56,9 +58,11 @@ class Pry
target = target() target = target()
opts = Slop.parse!(args) do |opt| opts = Slop.parse!(args) do |opt|
opt.banner "Usage: stat [OPTIONS] [METH]\n" \ opt.banner unindent <<-USAGE
"Show method information for method METH and set _file_ and _dir_ locals." \ Usage: stat [OPTIONS] [METH]
"e.g: stat hello_method" Show method information for method METH and set _file_ and _dir_ locals.
e.g: stat hello_method
USAGE
opt.on :M, "instance-methods", "Operate on instance methods." opt.on :M, "instance-methods", "Operate on instance methods."
opt.on :m, :methods, "Operate on methods." opt.on :m, :methods, "Operate on methods."
@ -100,11 +104,13 @@ class Pry
target = target() target = target()
opts = Slop.parse!(args) do |opt| opts = Slop.parse!(args) do |opt|
opt.banner "Usage: gist-method [OPTIONS] [METH]\n" \ opt.banner unindent <<-USAGE
"Gist the method (doc or source) to github.\n" \ Usage: gist-method [OPTIONS] [METH]
"Ensure the `gist` gem is properly working before use. http://github.com/defunkt/gist for instructions.\n" \ Gist the method (doc or source) to github.
"e.g: gist -m my_method\n" \ Ensure the `gist` gem is properly working before use. http://github.com/defunkt/gist for instructions.
"e.g: gist -d my_method\n" e.g: gist -m my_method
e.g: gist -d my_method
USAGE
opt.on :m, :method, "Gist a method's source." opt.on :m, :method, "Gist a method's source."
opt.on :d, :doc, "Gist a method's documentation." opt.on :d, :doc, "Gist a method's documentation."

View File

@ -17,14 +17,16 @@ class Pry
start_line_number, end_line_number, replacement_line = *args start_line_number, end_line_number, replacement_line = *args
opts = Slop.parse!(args.compact) do |opt| opts = Slop.parse!(args.compact) do |opt|
opt.banner %{Amend a line of input in multi-line mode. `amend-line N`, where the N in `amend-line N` represents line to replace. opt.banner unindent <<-USAGE
Amend a line of input in multi-line mode. `amend-line N`, where the N in `amend-line N` represents line to replace.
Can also specify a range of lines using `amend-line N..M` syntax. Passing '!' as replacement content deletes the line(s) instead. Aliases: %N
e.g amend-line 1 puts 'hello world! # replace line 1'
e.g amend-line 1..4 ! # delete lines 1..4
e.g amend-line 3 >puts 'goodbye' # insert before line 3
e.g amend-line puts 'hello again' # no line number modifies immediately preceding line
USAGE
Can also specify a range of lines using `amend-line N..M` syntax. Passing '!' as replacement content deletes the line(s) instead. Aliases: %N
e.g amend-line 1 puts 'hello world! # replace line 1'
e.g amend-line 1..4 ! # delete lines 1..4
e.g amend-line 3 >puts 'goodbye' # insert before line 3
e.g amend-line puts 'hello again' # no line number modifies immediately preceding line
}
opt.on :h, :help, "This message." do opt.on :h, :help, "This message." do
output.puts opt output.puts opt
end end
@ -56,7 +58,13 @@ e.g amend-line puts 'hello again' # no line number modifies immediately preced
command "play", "Play back a string variable or a method or a file as input. Type `play --help` for more information." do |*args| command "play", "Play back a string variable or a method or a file as input. Type `play --help` for more information." do |*args|
opts = Slop.parse!(args) do |opt| opts = Slop.parse!(args) do |opt|
opt.banner "Usage: play [OPTIONS] [--help]\nDefault action (no options) is to play the provided string variable\ne.g `play _in_[20] --lines 1..3`\ne.g `play -m Pry#repl --lines 1..-1`\ne.g `play -f Rakefile --lines 5`" opt.banner unindent <<-USAGE
Usage: play [OPTIONS] [--help]
Default action (no options) is to play the provided string variable
e.g `play _in_[20] --lines 1..3`
e.g `play -m Pry#repl --lines 1..-1`
e.g `play -f Rakefile --lines 5`
USAGE
opt.on :l, :lines, 'The line (or range of lines) to replay.', true, :as => Range opt.on :l, :lines, 'The line (or range of lines) to replay.', true, :as => Range
opt.on :m, :method, 'Play a method.', true opt.on :m, :method, 'Play a method.', true

View File

@ -9,9 +9,11 @@ class Pry
target = target() target = target()
opts = Slop.parse!(args) do |opt| opts = Slop.parse!(args) do |opt|
opt.banner "Usage: show-method [OPTIONS] [METH 1] [METH 2] [METH N]\n" \ opt.banner unindent <<-USAGE
"Show the source for method METH. Tries instance methods first and then methods by default.\n" \ Usage: show-method [OPTIONS] [METH 1] [METH 2] [METH N]
"e.g: show-method hello_method" Show the source for method METH. Tries instance methods first and then methods by default.
e.g: show-method hello_method
USAGE
opt.on :l, "line-numbers", "Show line numbers." opt.on :l, "line-numbers", "Show line numbers."
opt.on :b, "base-one", "Show line numbers but start numbering at 1 (useful for `amend-line` and `play` commands)." opt.on :b, "base-one", "Show line numbers but start numbering at 1 (useful for `amend-line` and `play` commands)."
@ -65,9 +67,11 @@ class Pry
target = target() target = target()
opts = Slop.parse!(args) do |opt| opts = Slop.parse!(args) do |opt|
opt.banner = "Usage: show-command [OPTIONS] [CMD]\n" \ opt.banner unindent <<-USAGE
"Show the source for command CMD.\n" \ Usage: show-command [OPTIONS] [CMD]
"e.g: show-command show-method" Show the source for command CMD.
e.g: show-command show-method
USAGE
opt.on :l, "line-numbers", "Show line numbers." opt.on :l, "line-numbers", "Show line numbers."
opt.on :f, :flood, "Do not use a pager to view text longer than one screen." opt.on :f, :flood, "Do not use a pager to view text longer than one screen."
@ -110,10 +114,12 @@ class Pry
command "edit", "Invoke the default editor on a file. Type `edit --help` for more info" do |*args| command "edit", "Invoke the default editor on a file. Type `edit --help` for more info" do |*args|
opts = Slop.parse!(args) do |opt| opts = Slop.parse!(args) do |opt|
opt.banner "Usage: edit [--no-reload|--reload] [--line LINE] [--temp|--ex|FILE[:LINE]]\n" \ opt.banner unindent <<-USAGE
"Open a text editor. When no FILE is given, edits the pry input buffer.\n" \ Usage: edit [--no-reload|--reload] [--line LINE] [--temp|--ex|FILE[:LINE]]
"Ensure #{text.bold("Pry.config.editor")} is set to your editor of choice.\n" \ Open a text editor. When no FILE is given, edits the pry input buffer.
"e.g: edit sample.rb" Ensure #{text.bold("Pry.config.editor")} is set to your editor of choice.
e.g: edit sample.rb
USAGE
opt.on :e, :ex, "Open the file that raised the most recent exception (_ex_.file)" opt.on :e, :ex, "Open the file that raised the most recent exception (_ex_.file)"
opt.on :t, :temp, "Open an empty temporary file" opt.on :t, :temp, "Open an empty temporary file"
@ -194,10 +200,12 @@ class Pry
target = target() target = target()
opts = Slop.parse!(args) do |opt| opts = Slop.parse!(args) do |opt|
opt.banner "Usage: edit-method [OPTIONS] [METH]\n" \ opt.banner unindent <<-USAGE
"Edit the method METH in an editor.\n" \ Usage: edit-method [OPTIONS] [METH]
"Ensure #{text.bold("Pry.config.editor")} is set to your editor of choice.\n" \ Edit the method METH in an editor.
"e.g: edit-method hello_method" Ensure #{text.bold("Pry.config.editor")} is set to your editor of choice.
e.g: edit-method hello_method
USAGE
opt.on :M, "instance-methods", "Operate on instance methods." opt.on :M, "instance-methods", "Operate on instance methods."
opt.on :m, :methods, "Operate on methods." opt.on :m, :methods, "Operate on methods."