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

19 commits

Author SHA1 Message Date
Kyrylo Silin
39fa8a9fc6 rubocop: fix offences of the Style/IfUnlessModifier cop 2019-03-02 11:03:54 +02:00
robert
c8f23b3464 automatically call Pry::Config::Lazy objects before returning them.
The pry-rails prompt uses `pry.config.prompt_name` but assumes it
will always be a string and never tries to `.call` the object, which means
we can end up with a prompt like this:

    [2] [vagrant][development] #<Pry::Config::Lazy:0x000000000fde07b0>(main)>

This commit solves the problem for pry-rails and other prompts who make
the same mistake by calling `.call` for them, automatically, upon read from
a config object.

The commit also removes the issue where every prompt has to deal with `prompt_name`
being a string / Proc-like object then acting accordingly.
2018-11-20 14:10:21 +01:00
Kyrylo Silin
bc26e405ea Simplify Prompt API
Before this change when you set a prompt, you have to do the following:

```rb
Pry.config.prompt = Pry::Prompt[:simple][:value]
```

The `[:value]` part was leaking implementation details and it proved to be an
unnecessary step.

With this change we can do the following:

```rb
Pry.config.prompt = Pry::Prompt[:simple]
```

`[:value]` is omitted.

I have also refactored some tests and removed irrelevant ones.

The Array API for prompt is deprecated:
`Pry.config.prompt = [proc {}, proc {}]` emits a warning now.
2018-11-17 05:26:25 +08:00
Kyrylo Silin
eb5564e5b1 prompt: raise ArgumentError when trying to add an existing prompt
This way we make sure nobody overwrites our default prompts.
2018-11-16 04:17:55 +08:00
Kyrylo Silin
0fc57889a1 rubocop: fix offences of the Lint/UnusedBlockArgument cop 2018-11-11 20:22:03 +08:00
Kyrylo Silin
d5c071fcd5
Merge pull request #1857 from r-obert/syntax-highlightable-prompt.rb
fix syntax highlighting of prompt.rb on Github & multiple editors
2018-11-11 16:05:48 +08:00
robert
cf2189351a fix syntax hightlighting of prompt.rb on GitHub & multiple editors. 2018-11-10 17:15:36 +01:00
Kyrylo Silin
28b6f5f7de prompt: delete deprecated MAP constant 2018-11-08 14:45:29 +08:00
robert
2ffb29aa14 do not create a new hash each time a prompt is accessed via Pry::Prompt[]
currently upon calling Pry::Prompt[:foo] a new Hash is created, and on all
subsequent calls a new Hash is also created. it's wasteful and careless,
so let's fix it.
2018-11-05 14:13:35 +01:00
Kyrylo Silin
60f20f8857 commands/change_prompt: incorporate 'list_prompts' functionality
Fixes #1829 (Merge `list-prompts` and `change-prompt` into one command)
2018-11-04 05:16:32 +08:00
Kyrylo Silin
54ccb43177 prompt: deprecate Pry::Prompt::MAP 2018-11-04 02:11:17 +08:00
Kyrylo Silin
3da930f908 prompt: add basic API for adding prompts
Fixes #1836 (Add an API for adding new prompts)
2018-11-04 02:11:15 +08:00
Kyrylo Silin
ace907b1b1 prompt: make it possible to set name dynamically
Fixes #1738 (Possible to make prompt_name dynamic?)

The user-facing API is the following:

```rb
Pry.config.prompt_name = Pry.lazy { rand(100) }

[1] 80(main)>
[2] 87(main)>
[3] 30(main)>
```
2018-10-28 19:02:14 +08:00
Kyrylo Silin
456f251675 prompt: refactor to reduce duplication
Since we always need to define two procs that look almost the same, duplication
was unavoidable. With help of method wrappers around procs we can reduce it.

As a bonus, the class has some YARD annotations now.
2018-10-28 16:21:56 +08:00
Kyrylo Silin
3deeeee115 config/default: rename prompt_safe_objects to prompt_safe_contexts
It makes sense to rename it because "objects" we are referring in the context of
prompt are actually prompt "contexts".
2018-10-28 16:07:44 +08:00
Kyrylo Silin
23a4ac6f0b Move prompt related code from pry.rb to prompt.rb
It makes a lot more sense to keep these procs under the `Pry::Prompt` namespace
than `Pry`, which is already heavily populated by other various things.
2018-10-28 05:35:27 +08:00
Kyrylo Silin
ae531ac738 prompt: use explicit nesting for class definition
Per https://github.com/rubocop-hq/ruby-style-guide#namespace-definition
2018-10-28 05:04:13 +08:00
Ryan Fitzgerald
20cdc22917 Various copy changes
Improves consistency of capitalization and punctuation across various
help text, plus some rewording and consolidating command groups.
2014-05-05 00:50:44 -07:00
Robert Gleeson
e617c7d420 add 'list-prompts' and 'change-prompt' commands.
the list-prompts command shows a list of available prompts as well
as the active prompt in the list. prompts are drawn with a name as
well as a short description.

change-prompt can be used to change the prompt by the name found in
the list-prompts command.
2014-03-19 14:53:28 +01:00