Skip to content

Standardize command related names - #873

Merged
st0012 merged 5 commits into
masterfrom
rename-command-constants
Feb 16, 2024
Merged

st0012 merged 5 commits into
masterfrom
rename-command-constants

Conversation

@st0012

@st0012 st0012 commented Feb 15, 2024 •

Copy link
Copy Markdown
Member

Before we expose command extension APIs, I think it'd be beneficial to first standardize (or even modernize) the names we use for command related concepts. This includes namespace, base class, and folder names:

  1. Rename lib/irb/extend-command.rb to lib/irb/command.rb
  2. Rename lib/irb/cmd/*.rb to lib/irb/command/*.rb
  3. Rename test/irb/test_cmd.rb to test/irb/test_command.rb
  4. Rename ExtendCommand to Command and alias it to Command
  5. Rename Nop to Base and alias it to Base

@st0012
st0012 force-pushed the rename-command-constants branch from d66af64 to 5cb1821 Compare February 15, 2024 17:10
@st0012

st0012 commented Feb 15, 2024 •

Copy link
Copy Markdown
Member Author

I think we can maybe postpone the raise of deprecation warning. Otherwise, gems need to start requiring IRB release with this PR + start referencing to the new constants to avoid the warning. But at the same time, it won't bring immediate benefit to them, nor us, other than having clearer names in their codebase.

Update: I decided not to raise deprecation warning on old constants.

@st0012
st0012 requested a review from a team February 15, 2024 20:01
@st0012
st0012 force-pushed the rename-command-constants branch from 7856c3d to 30ce967 Compare February 16, 2024 14:31
@tompng

tompng commented Feb 16, 2024

Copy link
Copy Markdown
Member

It looks like some repository is requiring "irb/cmd/nop". example: ruby/tracer, irbtoos search result

How about adding a file irb/cmd/nop.rb that only require irb/command/base?

1. Rename lib/irb/extend-command.rb to lib/irb/command.rb
2. Rename lib/irb/cmd/*.rb to lib/irb/command/*.rb
3. Rename test/irb/test_cmd.rb to test/irb/test_command.rb
4. Rename ExtendCommand to Command
@st0012
st0012 force-pushed the rename-command-constants branch from 30ce967 to 0d514c7 Compare February 16, 2024 16:37
@st0012

st0012 commented Feb 16, 2024

Copy link
Copy Markdown
Member Author

@tompng That's a good point 👍
I added the file back but it actually doesn't need to require anything. In both tracer and irbtools (and I assume other tools too), they are requiring irb as well, which currently already loads the base command.

@st0012
st0012 merged commit 462c128 into master Feb 16, 2024
@st0012
st0012 deleted the rename-command-constants branch February 16, 2024 16:47
matzbot pushed a commit to ruby/ruby that referenced this pull request Feb 16, 2024
(ruby/irb#873)

* Replace ExtendCommand with Command and standardize command related names

1. Rename lib/irb/extend-command.rb to lib/irb/command.rb
2. Rename lib/irb/cmd/*.rb to lib/irb/command/*.rb
3. Rename test/irb/test_cmd.rb to test/irb/test_command.rb
4. Rename ExtendCommand to Command

* Alias ExtendCommand to Command and deprecate it

* Rename Command::Nop to Command::Base

* Not deprecate old constants just yet

* Add lib/irb/cmd/nop.rb back

ruby/irb@462c1284af
znz added a commit to rurema/doctree that referenced this pull request Aug 3, 2026
#3408 のタスク実施。

until の追加(実装側の削除・移動時期は #3408 で確定済み):
- irb/ruby-token: 2.7.0(ruby/irb の Remove ruby-token.rb)
- irb/extend-command: 3.4(ruby/irb#873 で default_commands.rb に刷新)
- irb/cmd/{chws,help,load,pushws,subirb}: 3.4(lib/irb/command/ へ移動。
  cmd/nop.rb のみ 3.4 でも残存するため nop.md は対象外)
- irb/ext/save-history: 3.4(lib/irb/history.rb へ移動)

require リストの修正:
- 3.0 時点で実装に存在しない依存を削除: completion と ext/save-history
  の readline・ext/multi-irb の thread・ruby-lex の irb/ruby-token・
  input-method の readline(実装は 3.0 から無条件 require "reline"。
  reline の文書は未整備のためリンクは張らない)
- リンク先が 3.4 で消えるものを #%until 3.4 でゲート: irb.md の
  irb/extend-command・ext/use-loader の irb/cmd/load

境界 4 版(2.6/2.7/3.3/3.4)の DB で存否と requires を機械検証。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants