summaryrefslogtreecommitdiff
path: root/lib/irb/init.rb
AgeCommit message (Collapse)Author
2025-01-24Migrate irb and reline to the bundled gemsHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/12624
2025-01-22[ruby/irb] Add copy command (https://github.com/ruby/irb/pull/1044)Prajjwal Singh
Closes https://github.com/ruby/irb/pull/753 https://github.com/ruby/irb/commit/a24ac53d48 Notes: Merged: https://github.com/ruby/ruby/pull/12612
2025-01-11[ruby/irb] `IRB.conf[:SAVE_HISTORY]` should handle boolean valuesStan Lo
(https://github.com/ruby/irb/pull/1062) Although not documented, `IRB.conf[:SAVE_HISTORY]` used to accept boolean, which now causes `NoMethodError` when used. This commit changes the behavior to accept boolean values and adds tests for the behavior. https://github.com/ruby/irb/commit/8b1a07b2a8
2024-10-06[ruby/irb] Change default completor from regexp to auto, trytomoya ishida
TypeCompletor and fallback to RegexpCompletor. (https://github.com/ruby/irb/pull/1010) https://github.com/ruby/irb/commit/bb6a99d815
2024-05-10[ruby/irb] Add a new initialization step to validate IRB.conf'sStan Lo
values (https://github.com/ruby/irb/pull/953) Currently, users can only find out that they have set a wrong value for IRB configs when the value is used, with opaque error messages like "comparison of Integer with true failed (TypeError)". This commit adds a new initialization step to validate the values of some IRB configs, so that users can find out about the wrong values during the initialization of IRB. https://github.com/ruby/irb/commit/af8ef2948b
2024-03-16[ruby/irb] Fix irb_history saved to current directorytomoya ishida
(https://github.com/ruby/irb/pull/901) * Always save irb_history in HOME or XDG_CONFIG_HOME Also split irbrc search logic from irb_history search logic as a refactor * Remove IRB.conf[:RC_NAME_GENERATOR] because it's not configurable This conf is used to specify which irbrc to load. Need to configure before irbrc is loaded, so it's actually not configurable. This conf is also used for history file search, but it is configurable by conf[:HISTORY_FILE]. * remove rc_file_test because it is tested with rc_files, remove useless test setup * Make internal irbrc searching method private https://github.com/ruby/irb/commit/11d03a6ff7
2024-03-05[ruby/irb] Add the ability to fetch and load multiple irb files.Haroon Ahmed
(https://github.com/ruby/irb/pull/859) This allows hierarchy when loading rc files for example both files below are loaded; project/.irbrc ~/.irbrc https://github.com/ruby/irb/commit/b53ebc6655 Co-authored-by: Stan Lo <[email protected]>
2024-02-23[ruby/irb] Turn on frozen literal in filesStan Lo
(https://github.com/ruby/irb/pull/881) https://github.com/ruby/irb/commit/83d90550c2
2024-02-07[ruby/irb] Polish tracer integration and testsStan Lo
(https://github.com/ruby/irb/pull/864) * Remove useless ivar * Simplify tracer test setup * Treat tracer like a normal development dependency * Only require ext/tracer when value is truthy * Make tracer integration skip IRB traces https://github.com/ruby/irb/commit/a97a4129a7
2024-02-01[ruby/irb] Skip re-setup when creating a child sessionNuno Silva
(https://github.com/ruby/irb/pull/850) https://github.com/ruby/irb/commit/06b2d00dd3
2023-12-20[ruby/irb] Warn users about errors in loading RC filesStan Lo
(https://github.com/ruby/irb/pull/817) 1. Because `IRB.rc_file` always generates an rc file name, even if the file doesn't exist, we should check the file exists before trying to load it. 2. If any type of errors occur while loading the rc file, we should warn the user about it. https://github.com/ruby/irb/commit/37ffdc6b19
2023-12-13[ruby/irb] Warn and do nothing if block is passed to measure commandtomoya ishida
(https://github.com/ruby/irb/pull/813) https://github.com/ruby/irb/commit/e79a90a1e6
2023-11-26[ruby/irb] Display aliases in help messageStan Lo
(https://github.com/ruby/irb/pull/788) Similar to Pry, it displays user-defined aliases in the help message with a dedicated section. With the current default aliases, it looks like: ``` ...other sections... Aliases $ Alias for `show_source` @ Alias for `whereami` ``` https://github.com/ruby/irb/commit/2a0eacc891
2023-11-26[ruby/irb] Support disabling pagerStan Lo
(https://github.com/ruby/irb/pull/783) With either `IRB.conf[:USE_PAGER] = false` or `--no-pager` commnad line flag. I decided use `--no-pager` instead of `--use-pager` because it matches with Pry and git's command line flags. https://github.com/ruby/irb/commit/df1c3b9042
2023-11-21[ruby/irb] Enable Setting Completer Type through `IRB_COMPLETOR`ima1zumi
(https://github.com/ruby/irb/pull/771) I propose introducing the capability to set the IRB completion kinds via an environment variable, specifically `IRB_COMPLETOR=type`. This feature aims to enhance the Rails console experience by allowing Rails users to specify their preferred completion more conveniently. Currently, when using the Rails console, there's no straightforward way to globally set the type completion across a Rails application repository. It's possible to configure this setting by placing a `.irbrc` file at the project root. However, using a .irbrc file is not ideal as it allows for broad configurations and can potentially affect the production environment. My suggestion focuses on allowing users to set the completion to 'type' in a minimal. This enhancement would be particularly beneficial for teams writing RBS in their Rails applications. This type completer, integrated with RBS, would enhance completion accuracy, improving the Rails console experience. https://github.com/ruby/irb/commit/032f6da25f
2023-11-09[ruby/irb] Add command line option to select which completor to usetomoya ishida
(https://github.com/ruby/irb/pull/754) * Add command line option to select which completor to use * Add test for completor argv https://github.com/ruby/irb/commit/1dec2708c9
2023-11-08[ruby/irb] Type based completion using Prism and RBStomoya ishida
(https://github.com/ruby/irb/pull/708) * Add completor using prism and rbs * Add TypeCompletion test * Switchable completors: RegexpCompletor and TypeCompletion::Completor * Add completion info to irb_info * Complete reserved words * Fix [*] (*) {**} and prism's change of KeywordParameterNode * Fix require, frozen_string_literal * Drop prism<=0.16.0 support * Add Completor.last_completion_error for debug report * Retrieve `self` and `Module.nesting` in more safe way * Support BasicObject * Handle lvar and ivar get exception correctly * Skip ivar reference test of non-self object in ruby < 3.2 * BaseScope to RootScope, move method objects constant under Methods * Remove unused Splat struct * Drop deeply nested array/hash type calculation from actual object. Now, calculation depth is 1 * Refactor loading rbs in test, change preload_in_thread not to cache Thread object * Use new option added in prism 0.17.1 to parse code with localvars * Add Prism version check and warn when :type completor cannot be enabled * build_type_completor should skip truffleruby (because endless method definition is not supported) https://github.com/ruby/irb/commit/1048c7ed7a
2023-10-21[ruby/irb] Minor refactors around irb.rbStan Lo
(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 https://github.com/ruby/irb/commit/cf23be4395
2023-08-29[ruby/irb] Remove unused `PROMPT_N`Summer ☀️
(https://github.com/ruby/irb/pull/685) https://github.com/ruby/irb/commit/66e69fa0dc
2023-08-12[ruby/irb] Drop showing indent level number in DEFAULT prompt andtomoya ishida
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 https://github.com/ruby/irb/commit/3847532e54
2023-02-25[ruby/irb] Remove unused Structima1zumi
(https://github.com/ruby/irb/pull/522) https://github.com/ruby/irb/commit/97dae166ae
2023-01-11[ruby/irb] Formatting to header stylesHiroshi SHIBATA
https://github.com/ruby/irb/commit/cef125850d
2023-01-11[ruby/irb] Removed Release Version and Revisions for old VCS softwareHiroshi SHIBATA
https://github.com/ruby/irb/commit/07fae94862
2022-12-27[ruby/irb] Fix wrong conf path with XDG_CONFIG_HOME. It should be under the ↵Hiroshi SHIBATA
HOME directory, not current directory https://github.com/ruby/irb/commit/33a5e55ffd
2022-12-06[ruby/irb] Allow disabling autocompletion withStan Lo
`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-11-21[ruby/irb] Add commands to start and use the debuggerTakashi Kokubun
(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 https://github.com/ruby/irb/commit/976100c1c2
2022-11-15[ruby/irb] Deprecate reidline flagsst0012
https://github.com/ruby/irb/commit/9957e83f7d
2022-11-10[ruby/irb] Make $ and @ default aliasesTakashi Kokubun
(https://github.com/ruby/irb/pull/438) https://github.com/ruby/irb/commit/0613589476
2022-11-03[ruby/irb] Allow non-identifier aliases like Pry's @ and $Takashi Kokubun
(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 https://github.com/ruby/irb/commit/e23db5132e
2022-10-28[ruby/irb] Do not make non-existent XDG directory on startNobuyoshi Nakada
(https://github.com/ruby/irb/pull/357) https://github.com/ruby/irb/commit/298b134792
2022-10-28[ruby/irb] Update regarding NO_COLOR valueNobuyoshi Nakada
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. https://github.com/ruby/irb/commit/46e0f7e370 Co-authored-by: Stan Lo <[email protected]>
2022-09-17[ruby/irb] Support --noscript option to not use first non-option argument as ↵Jeremy Evans
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] https://github.com/ruby/irb/commit/4192683ba2
2021-10-11[ruby/irb] Add --extra-doc-dir option to show doc dialogaycabta
https://github.com/ruby/irb/commit/3f79cb506f
2021-08-30Add --autocomplete / --noautocomplete optionsaycabta
2021-06-21[ruby/irb] Improve stackprof measureUlysse Buonomo
Allow usage of more detailed args when setting stackprof callback. Signed-off-by: Ulysse Buonomo <[email protected]> https://github.com/ruby/irb/commit/c9d101f450
2021-05-24[ruby/irb] respect NO_COLOR environment variableMark Delk
When `NO_COLOR` is set to any non-nil value, output is not colorized. See https://no-color.org/ https://github.com/ruby/irb/commit/401d0916fe
2021-02-06[ruby/irb] Enable to reassign a new block with "measure" commandaycabta
https://github.com/ruby/irb/commit/b444573aa2
2021-02-06[ruby/irb] Allow "measure" command to take blockaycabta
https://github.com/ruby/irb/commit/20f1ca23e9
2020-12-24[ruby/irb] Try not to register the exact same measuring method twiceaycabta
https://github.com/ruby/irb/commit/cc66b5573e
2020-12-22[ruby/irb] Support arg for measure commandaycabta
https://github.com/ruby/irb/commit/b43f35d8f3
2020-12-20[ruby/irb] Add measure commandaycabta
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 } https://github.com/ruby/irb/commit/3899eaf2e2
2020-12-17[ruby/irb] Change context-mode's default to new mode 4.Marc-Andre Lafortune
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 https://github.com/ruby/irb/commit/25c731cb2f
2020-12-17[ruby/irb] Enable deprecation warnings when using -W or -wJeremy Evans
Requested in Ruby Bug 17377 https://github.com/ruby/irb/commit/698f6eb34a
2020-09-19[ruby/irb] Drop OMIT_ON_ASSIGNMENT and add :truncate option for ↵aycabta
ECHO_ON_ASSIGNMENT https://github.com/ruby/irb/commit/4c89b0775b
2020-09-14[ruby/irb] Add OMIT_ON_ASSIGNMENTaycabta
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. https://github.com/ruby/irb/commit/c5ea79d5ce
2020-04-23Support XDG_* (#2174)Hiroshi SHIBATA
* 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 Notes: Merged-By: hsbt <[email protected]>
2020-01-14Use Reline.encoding_system_needs if existsaycabta
2020-01-14Remove an unused setting variableaycabta
2019-11-25Remove e2mmap dependencyaycabta
2019-11-21Add a warning message and --legacy of an alias of --singlelineaycabta