Commit graph

89 commits

Author SHA1 Message Date
Stan Lo
745879b5ed [ruby/irb] Minor refactors around irb.rb
(https://github.com/ruby/irb/pull/736)

* Remove dead method

* Simplify IRB.version

* Move private Irb methods together

* Centralise @CONF initialization/assignment in init.rb

* Move attr_* calls above initialize method

cf23be4395
2023-10-21 18:06:00 +00:00
Summer ☀️
0cd92819c9
[ruby/irb] Remove unused PROMPT_N
(https://github.com/ruby/irb/pull/685)

66e69fa0dc
2023-08-29 18:15:05 +09:00
tomoya ishida
e1683b4958 [ruby/irb] Drop showing indent level number in DEFAULT prompt and
INF_RUBY prompt
(https://github.com/ruby/irb/pull/679)

* Drop showing indent level number in DEFAULT prompt and INF_RUBY prompt

* Update prompt part of test_rendering's expected result

3847532e54
2023-08-12 10:19:24 +00:00
ima1zumi
672b81b090 [ruby/irb] Remove unused Struct
(https://github.com/ruby/irb/pull/522)

97dae166ae
2023-02-25 16:50:33 +00:00
Hiroshi SHIBATA
7e283c585e [ruby/irb] Formatting to header styles
cef125850d
2023-01-11 22:29:10 +00:00
Hiroshi SHIBATA
c7bb8d67b7 [ruby/irb] Removed Release Version and Revisions for old VCS software
07fae94862
2023-01-11 22:29:09 +00:00
Hiroshi SHIBATA
c09f342d04 [ruby/irb] Fix wrong conf path with XDG_CONFIG_HOME. It should be under the HOME directory, not current directory
33a5e55ffd
2022-12-27 00:09:12 +00:00
Stan Lo
9aa18f61f2 [ruby/irb] Allow disabling autocompletion with
`IRB_USE_AUTOCOMPLETE=false`
(https://github.com/ruby/irb/pull/469)

* Allow using IRB_USE_AUTOCOMPLETE=false to disable autocompletion

Currently, the only 2 ways to disable autocompletion are:

1. Create `.irbrc` and set `IRB.conf[:USE_AUTOCOMPLETE] = false`
2. Add the `--noautocomplete` flag when using the `irb` executable

Both of them are less convenient than setting a env var and are
lesser known to devs.

And given the number of problems the autocompletion has (see #445), I
think we should allow disabling it with a simple `IRB_USE_AUTOCOMPLETE=false`.

* Mention some env var configs in the README
2022-12-06 00:53:32 +00:00
Takashi Kokubun
c9fbc779a6 [ruby/irb] Add commands to start and use the debugger
(https://github.com/ruby/irb/pull/449)

* Seamlessly integrate a few debug commands

* Improve the break command support

* Utilize skip_src option if available

* Add step and delete commands

* Write end-to-end tests for each debugger command

* Add documentation

* Add backtrace, info, catch commands

976100c1c2
2022-11-21 08:46:27 +00:00
st0012
34320d883f [ruby/irb] Deprecate reidline flags
9957e83f7d
2022-11-15 10:08:29 +00:00
Takashi Kokubun
0de3bc92b4 [ruby/irb] Make $ and @ default aliases
(https://github.com/ruby/irb/pull/438)

0613589476
2022-11-10 17:31:15 +00:00
Takashi Kokubun
a13836e70d [ruby/irb] Allow non-identifier aliases like Pry's @ and $
(https://github.com/ruby/irb/pull/426)

* Allow non-identifier aliases

* Move the configuration to IRB.conf

* Avoid abusing method lookup for symbol aliases

* Add more alias tests

* A small optimization

* Assume non-nil Context

* Load IRB.conf earlier

e23db5132e
2022-11-03 22:09:55 +00:00
Nobuyoshi Nakada
4021c6565f [ruby/irb] Do not make non-existent XDG directory on start
(https://github.com/ruby/irb/pull/357)


298b134792
2022-10-28 09:36:28 +00:00
Nobuyoshi Nakada
56c97a6621 [ruby/irb] Update regarding NO_COLOR value
https://no-color.org has been updated (jcs/no_color#83):

> Command-line software which adds ANSI color to its output by default
should check for a `NO_COLOR` environment variable that, when present
and **not an empty string** (regardless of its value), prevents the
addition of ANSI color.

46e0f7e370

Co-authored-by: Stan Lo <stan001212@gmail.com>
2022-10-28 09:30:24 +00:00
Jeremy Evans
b07db96744 [ruby/irb] Support --noscript option to not use first non-option argument as script
Also add --script option to turn the option back on.

Previously there wasn't a way to get an interactive IRB session
and access arguments provided on the command line.

Additionally, handle `-` as script as stdin. In Unix-like tools, `-`
means to take standard input instead of a file.  This doesn't
result in exactly the same output for:

```
echo 'p ARGV' > args.rb; irb args.rb a b c
```

and

```
echo 'p ARGV' | irb - a b c
```

Due to how irb handles whether stdin is a tty.

However, this change allows use of `-` as a argument, instead of
giving an unrecognized switch error. This required some small
changes to context.rb (to handle `-` as standard input) and
input-method.rb (to have FileInputMethod accept IO arguments in
addition to strings).

Implements [Feature #15371]

4192683ba2
2022-09-17 02:25:26 +09:00
aycabta
866a09dd9e [ruby/irb] Add --extra-doc-dir option to show doc dialog
3f79cb506f
2021-10-11 21:12:57 +09:00
aycabta
ece4ed0da7 Add --autocomplete / --noautocomplete options 2021-08-30 02:45:13 +09:00
Ulysse Buonomo
5cc11845b2 [ruby/irb] Improve stackprof measure
Allow usage of more detailed args when setting stackprof callback.

Signed-off-by: Ulysse Buonomo <buonomo.ulysse@gmail.com>

c9d101f450
2021-06-21 18:03:49 +09:00
Mark Delk
b8ffb1c46f [ruby/irb] respect NO_COLOR environment variable
When `NO_COLOR` is set to any non-nil value, output is not colorized.

See https://no-color.org/

401d0916fe
2021-05-24 11:55:58 +09:00
aycabta
7b354cf67b [ruby/irb] Enable to reassign a new block with "measure" command
b444573aa2
2021-02-06 21:09:31 +09:00
aycabta
5704b5fe5e [ruby/irb] Allow "measure" command to take block
20f1ca23e9
2021-02-06 20:45:08 +09:00
aycabta
167dc37632 [ruby/irb] Try not to register the exact same measuring method twice
cc66b5573e
2020-12-24 23:26:22 +09:00
aycabta
4131cd05be [ruby/irb] Support arg for measure command
b43f35d8f3
2020-12-22 23:45:43 +09:00
aycabta
9f08e3c703 [ruby/irb] Add measure command
You can use "measure" command to check performance in IRB like below:

  irb(main):001:0> 3
  => 3
  irb(main):002:0> measure
  TIME is added.
  => nil
  irb(main):003:0> 3
  processing time: 0.000058s
  => 3
  irb(main):004:0> measure :off
  => nil
  irb(main):005:0> 3
  => 3

You can set "measure :on" by "IRB.conf[:MEASURE] = true" in .irbrc, and, also,
set custom performance check method:

  IRB.conf[:MEASURE_PROC][:CUSTOM] = proc { |context, code, line_no, &block|
    time = Time.now
    result = block.()
    now = Time.now
    puts 'custom processing time: %fs' % (Time.now - time) if IRB.conf[:MEASURE]
    result
  }

3899eaf2e2
2020-12-20 16:23:59 +09:00
Marc-Andre Lafortune
980f994b3b [ruby/irb] Change context-mode's default to new mode 4.
This new mode uses a copy of the TOPLEVEL_BINDING. This is compatible with refinements (contrary to mode 3), while keeping nested IRB sessions separate

25c731cb2f
2020-12-17 20:24:08 +09:00
Jeremy Evans
753222d72c [ruby/irb] Enable deprecation warnings when using -W or -w
Requested in Ruby Bug 17377

698f6eb34a
2020-12-17 20:23:49 +09:00
aycabta
555ea83344 [ruby/irb] Drop OMIT_ON_ASSIGNMENT and add :truncate option for ECHO_ON_ASSIGNMENT
4c89b0775b
2020-09-19 05:13:08 +09:00
aycabta
e468d9f49c [ruby/irb] Add OMIT_ON_ASSIGNMENT
Omit the results evaluated at assignment if they are too long.

The behavior of ECHO_ON_ASSIGNMENT being on by default is hard to understand,
so I change it to off by default. Instead, we turn OMIT_ON_ASSIGNMENT on by
default. The result is displayed on assignment, but it will always be short
and within one line of the screen.

c5ea79d5ce
2020-09-14 02:13:11 +09:00
Hiroshi SHIBATA
5c6269c459
Support XDG_* (#2174)
* Support XDG_CONFIG_HOME for gemrc.

* Support XDG_DATA_HOME for .gem

* Added test for XDG_DATA_HOME

* Do not reuse environmental variable.

* Unify .rdoc path to RDoc.home.

* Support XDG_DATA_HOME for .rdoc

* Ignore exists?

* Extracted config_home path

* Use XDG_CONFIG_HOME for default credential path

* Fixed inconsistency location.

* Fixed the broken tests.

* Support XDG_CONFIG_HOME for irbrc

* Introduce Gem.cache_home as XDG_CACHE_HOME

* Use Gem.cache_home instead of Gem.config_home for the credential file of RubyGems.

* Initialized the old configurations

* Fixed test failure related the configuration initialization

* restore XDG_DATA_HOME

* Fixed the broken examples of bundler with XDG_*

* Do not modify environmental variable on test file

* Use XDG_DATA_HOME insted of XDG_CACHE_HOME for credential file

* stub out Gem.data_home

* Move dir accessor to defaults.rb file

* Use XDG_DATA_HOME for signed gem features

* Use XDG_DATA_HOME for spec cache

* Do not rely on Gem.user_home

* Gem.user_home is always exists. Don't need to use FileUitls.mkdir_p

* Bump support version to RubyGems 3.2.0+

* Removed the needless fallback configuration

* Fixed the inconsistency methods that are find_config_file and config_file

* Use Gem.configuration.credentials_path instead of hard-coded path

* gem_path is always provided

* Removed the duplicated code of find_home

* Also removed the duplicated code of user_home

* use Gem::UNTAINT instead of untaint for surpressing the warnings

* Use File.directory

* Restore XDG_DATA_HOME

* Use File.write
2020-04-23 19:16:06 +09:00
aycabta
8c3efa4940 Use Reline.encoding_system_needs if exists 2020-01-14 15:40:38 +09:00
aycabta
a2638c0d87 Remove an unused setting variable 2020-01-14 15:40:38 +09:00
aycabta
51ea1abb5f Remove e2mmap dependency 2019-11-25 05:38:09 +09:00
aycabta
eee70b41d4 Add a warning message and --legacy of an alias of --singleline 2019-11-21 02:44:35 +09:00
aycabta
91bf3b7a77 Use singleline/multiline instead of readline/reidline 2019-11-21 02:44:35 +09:00
aycabta
bc0da8e3ff Generate history file path correctly when $HOME/.irbrc doesn't exist 2019-11-20 08:19:58 +09:00
Steven Willis
9d2fed2ccd Don't echo results of assignment expressions 2019-08-16 06:02:45 +09:00
aycabta
43b52ac0a5 Revert "Don't echo results of assignment expressions"
This reverts commit 1ee88c51b3.
2019-08-06 20:28:48 +09:00
Steven Willis
1ee88c51b3 Don't echo results of assignment expressions 2019-08-06 20:15:07 +09:00
Kazuhiro NISHIYAMA
b789648830
Change PROMPT_S of simple-prompt
When input `"` or `/` with simple-prompt,

Before:
`"` or `/`
(prompt disappeared and indent is changed)

After:
`"> "` or `/> /`
(indent is unchanged since `>> `)
2019-07-15 10:29:48 +09:00
aycabta
078e50c5e9 Save history in IRB is enabled by default 2019-07-15 01:16:18 +09:00
aycabta
6d57369105 Auto indent in IRB is enabled by default 2019-07-15 01:07:37 +09:00
aycabta
260235ce87 Use Reline as Reidline multiline editor in IRB 2019-05-25 02:16:19 +09:00
aycabta
3a9008b984 Add --colorize and --nocolorize options to IRB 2019-05-21 08:57:21 +09:00
aycabta
94b740b249 Use Ripper for IRB
The debug option of IRB is deleted because it's just for IRB's pure Ruby
parser.
2019-04-30 14:40:06 +09:00
Nobuyoshi Nakada
f4f66bd11c
Revert "IRB is improved with Reline and RDoc, take 2"
Accidentally merged when 89271d4a37
"Adjusted indents".
2019-04-23 21:55:29 +09:00
aycabta
f2cd4f4cd0
IRB is improved with Reline and RDoc, take 2 2019-04-23 20:08:02 +09:00
aycabta
51cec00953 Revert "IRB is improved with Reline and RDoc"
This reverts commit 7f273ac6d0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-21 09:13:49 +00:00
aycabta
7f273ac6d0 IRB is improved with Reline and RDoc
Reline is a readline stdlib compatible library. It also supports
multiline input. IRB is improved with Reline and supports multiline.
Besides, supports showing documents when completed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-20 08:51:20 +00:00
marcandre
e859e668d2 lib/*: Prefer require_relative over require.
[#15206] [Fix GH-1976]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-02 17:52:33 +00:00
kazu
38054f99aa Remove unnecessary :
Before:

`.../irb/init.rb:280: warning: :LoadError: cannot load such file -- hoge`

After:

`.../irb/init.rb:280: warning: LoadError: cannot load such file -- hoge`

[ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 15:01:07 +00:00