1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00
Commit graph

15 commits

Author SHA1 Message Date
Conrad Irwin
e073092e7c Fix the superficial slop errors 2012-05-29 20:33:52 -07:00
Conrad Irwin
a970d5b29e Show the contents of the process method by default
When creating a command using a custom subclass there may not be a
readily available block. In that case defaulting to the process method
seems reasonable for now.
2012-04-01 16:20:35 -07:00
Conrad Irwin
12a4eb5784 Add a test for custom-subclass based commands 2012-04-01 16:18:11 -07:00
John Mair
8ace207020 :takes_block now false by default, removed &block
* blocks can no longer be passed explicitly into commands via command "blah", "desc" |&block| (1.8 compatibility problems)
* blocks must be explicitly enabled for a command with the :takes_block => true option
2012-02-27 14:34:05 +13:00
John Mair
8e99eddf00 Command block syntax now requires "| do" or "| {"
e.g:
command "hello", "desc" do |&block|
  block.call
end

(pry)> hello | do
(pry)*   puts "mommy, make me all silver!"
(pry)* end
mommy, make me all silver!

* Blocks are now available by default, turn off explicitly with :takes_block => false
2012-02-27 01:08:56 +13:00
John Mair
87b141a6ab added closure test for command blocks
e.g
var = 10
my-command { puts var }
2012-02-24 12:47:09 +13:00
John Mair
44f057198f added tests for multiple params to block 2012-02-24 05:23:17 +13:00
John Mair
90d6f3eefb added support for passing blocks to commands
* Example, using &block:
 Pry.commands.command "tobina", "desc", :takes_block => true do |&block|
   block.call
 end

(pry)> tobina { puts "hi" }
hi
(pry)>
* Works with process(&block) too (for create_command)
* Works with do/end blocks and {} blocks, both single and multi-line

* Example, using command_block:
  Pry.commands.command "tobina", "desc", :takes_block => true do
    command_block.call
  end
2012-02-24 03:40:52 +13:00
Conrad Irwin
656b1fc9aa Put "help" command in its own file 2012-02-22 23:35:07 -08:00
Conrad Irwin
2a6f391275 Check for command-name collision on assignment [Fixes #450] 2012-01-28 19:44:45 -08:00
John Mair
312bb7eee4 command_class no longer alias for create_command
* removed as an alias
* converted remaining commands over to create_command
* removed references in tests
2012-01-22 12:17:43 +13:00
Conrad Irwin
76924d98b3 Don't clobber pre-existing options when adding new ones 2012-01-14 20:54:30 -08:00
Conrad Irwin
45c6492e7e Split CommandProcessor responsibility between CommandSet and Command
The CommandSet is responsible for storing Commands, while the Commands
themselves are responsible for all the parsing.

(Before this change, the CommandProcessor used to do both the searching
within the CommandSet's and also the tokenization of command arguments)
2012-01-03 01:35:32 +00:00
Conrad Irwin
bb48077241 Remove parse_options! API
Having classy commands means it's much easier to implement, so we just
require those instead.
2011-12-31 16:05:14 +00:00
Conrad Irwin
f8c2d04dce Test new command api 2011-12-31 15:24:11 +00:00