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

30 commits

Author SHA1 Message Date
☈king
848b6bdbeb Rename for tabcompletion-friendliness. 2012-11-15 18:59:51 -06:00
Conrad Irwin
7a5d21ba74 Add a space when completing command names and long options 2012-11-14 01:54:30 -08:00
Ryan Fitzgerald
aefbe8502c Remove stray hash 2012-09-08 23:16:29 -07:00
Ryan Fitzgerald
976d9de2d8 Directify test_command.rb 2012-09-08 23:12:25 -07:00
Ryan Fitzgerald
1a1ea323ea Make pry_tester accept Pry ctor options 2012-09-08 22:46:50 -07:00
Ryan Fitzgerald
9b52d358ae Remove some unnecessary mock_prys 2012-09-08 22:29:00 -07:00
Ryan Fitzgerald
f0a16e2cc3 Tolerate Bond not being present 2012-09-05 22:39:29 -07:00
Conrad Irwin
246b88cf16 Bond completion includes commands 2012-08-20 23:57:51 -07:00
Reginald Tan
3836179181 Depracated show-command and moved its functionality to show-source
Also, show-doc on commands now displays their banner
2012-08-14 00:18:53 -04:00
Ryan Fitzgerald
25cbe43137 Move all commands into individual files 2012-08-11 17:33:37 -07:00
Kyrylo Silin
caeb6b58b6 Refactor tests for command groups
We should not rely on default commands, because they can be removed or
shuffled around in the future. Use our custom command in the tests.

Also, add a test that ensures that a group does not disappear after the
call without parameters.

Reported-by: John Mair <jrmair@gmail.com>
Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
2012-07-06 21:23:31 +03:00
Kyrylo Silin
e0fdf24461 Fix wrong command groups
Fix issue #631 (In `help` output: aliases are no longer grouped under
Aliases heading but under (other))

Forbid redefining a group of a command once it is initialized. Also, add
some unit tests, checking for that, so we won't miss this if it happens
next time.

Reported-by: John Mair <jrmair@gmail.com>
Cc: Rob Gleeson <rob@flowof.info>
Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
2012-07-05 23:31:03 +03:00
Kyrylo Silin
6a54e34dad Fix indentation level
Adjust wrong nesting (remove extra blank from each line) in some tests.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
2012-07-05 22:40:54 +03:00
John Mair
3bfd65d5d8 Fix whereami with tests, closes #595 2012-06-16 01:25:07 +12:00
John Mair
0871ac65f6 Provide a place for commands to store state.
Commands can store state on an  `OpenStruct` exposed via the `state` method.
This `OpenStruct` is guaranteed to be unique to the command and to the associated Pry instance.

e.g

create_command "my-test" do
  def process
    state.my_state ||= 0
    state.my_state += 1
  end
end

The above `state.my_state` variable will increment by one for each invocation of `my-test`.
Further, it will not intefere with any state on `my-test` for any other Pry instance or with
any `state.my_state` variables defined for other commands on the same Pry instance.
2012-06-16 00:45:04 +12:00
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