Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add edit command #453

Merged
merged 5 commits into from
Nov 20, 2022
Merged

Add edit command #453

merged 5 commits into from
Nov 20, 2022

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Nov 19, 2022

Name

I originally wanted to name it open. But since ruby/debug has an edit command (the inspiration of this feature), I think it's better to match it.

Usages

Editor is determined by ENV["EDITOR"]

  • edit - opens the current context's file in the editor
  • edit foo.rb - opens foo.rb in the editor if it exists

It also supports show_source compatible arguments, like

  • edit Foo
  • edit Foo#bar
  • edit Foo.baz

In these cases, it'll use show_source to resolve the argument's path and open them in the editor.

Exceptions

  • If irb can't find a file with the argument, nor can ShowSource#find_source resolve its source, it prints a message and stops.
  • If ENV["EDITOR"] is not defined, the command also prints a message and stops.

@st0012 st0012 force-pushed the suppot-edit-command branch 4 times, most recently from 02e3d69 to ff6af14 Compare November 19, 2022 12:46
lib/irb/cmd/edit.rb Outdated Show resolved Hide resolved
Copy link
Member

@k0kubun k0kubun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I merged #451. Let's add edit to it too 👍

@st0012 st0012 force-pushed the suppot-edit-command branch from ff6af14 to b54e32f Compare November 20, 2022 00:40
@st0012 st0012 force-pushed the suppot-edit-command branch from b54e32f to d7a58f4 Compare November 20, 2022 00:47
lib/irb/cmd/show_source.rb Outdated Show resolved Hide resolved
Copy link
Member

@k0kubun k0kubun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@k0kubun k0kubun merged commit 4321674 into ruby:master Nov 20, 2022
matzbot pushed a commit to ruby/ruby that referenced this pull request Nov 20, 2022
* Add edit command

* Make find_source a public singleton method

* Add document for the edit command

* Make find_end private

* Remove duplicated private

ruby/irb@4321674aa7
Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
@st0012 st0012 deleted the suppot-edit-command branch November 20, 2022 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants