-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standardize command related names (#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
- Loading branch information
Showing
33 changed files
with
158 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,4 @@ | ||
# frozen_string_literal: false | ||
# | ||
# nop.rb - | ||
# by Keiju ISHITSUKA(keiju@ruby-lang.org) | ||
# | ||
# frozen_string_literal: true | ||
|
||
module IRB | ||
# :stopdoc: | ||
|
||
module ExtendCommand | ||
class CommandArgumentError < StandardError; end | ||
|
||
class Nop | ||
class << self | ||
def category(category = nil) | ||
@category = category if category | ||
@category | ||
end | ||
|
||
def description(description = nil) | ||
@description = description if description | ||
@description | ||
end | ||
|
||
private | ||
|
||
def string_literal?(args) | ||
sexp = Ripper.sexp(args) | ||
sexp && sexp.size == 2 && sexp.last&.first&.first == :string_literal | ||
end | ||
end | ||
|
||
def self.execute(irb_context, *opts, **kwargs, &block) | ||
command = new(irb_context) | ||
command.execute(*opts, **kwargs, &block) | ||
rescue CommandArgumentError => e | ||
puts e.message | ||
end | ||
|
||
def initialize(irb_context) | ||
@irb_context = irb_context | ||
end | ||
|
||
attr_reader :irb_context | ||
|
||
def execute(*opts) | ||
#nop | ||
end | ||
end | ||
end | ||
|
||
# :startdoc: | ||
end | ||
# This file is just a placeholder for backward-compatibility. | ||
# Please require 'irb' and inheirt your command from `IRB::Command::Base` instead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# frozen_string_literal: false | ||
# | ||
# nop.rb - | ||
# by Keiju ISHITSUKA(keiju@ruby-lang.org) | ||
# | ||
|
||
module IRB | ||
# :stopdoc: | ||
|
||
module Command | ||
class CommandArgumentError < StandardError; end | ||
|
||
class Base | ||
class << self | ||
def category(category = nil) | ||
@category = category if category | ||
@category | ||
end | ||
|
||
def description(description = nil) | ||
@description = description if description | ||
@description | ||
end | ||
|
||
private | ||
|
||
def string_literal?(args) | ||
sexp = Ripper.sexp(args) | ||
sexp && sexp.size == 2 && sexp.last&.first&.first == :string_literal | ||
end | ||
end | ||
|
||
def self.execute(irb_context, *opts, **kwargs, &block) | ||
command = new(irb_context) | ||
command.execute(*opts, **kwargs, &block) | ||
rescue CommandArgumentError => e | ||
puts e.message | ||
end | ||
|
||
def initialize(irb_context) | ||
@irb_context = irb_context | ||
end | ||
|
||
attr_reader :irb_context | ||
|
||
def execute(*opts) | ||
#nop | ||
end | ||
end | ||
|
||
Nop = Base | ||
end | ||
|
||
# :startdoc: | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.