mirror of
https://github.com/ruby/ruby.git
synced 2025-09-18 10:03:59 +02:00

(https://github.com/ruby/irb/pull/948)
* Remove unnecessary code from command tests
* Improve help message for no meta commands
1. Add placeholder values for both command category and description
2. Update help command's output to give different types of categories
more explicit ordering
b1ef58aeff
62 lines
1.2 KiB
Ruby
62 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
#
|
|
# nop.rb -
|
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
|
#
|
|
|
|
module IRB
|
|
# :stopdoc:
|
|
|
|
module Command
|
|
class CommandArgumentError < StandardError; end
|
|
|
|
def self.extract_ruby_args(*args, **kwargs)
|
|
throw :EXTRACT_RUBY_ARGS, [args, kwargs]
|
|
end
|
|
|
|
class Base
|
|
class << self
|
|
def category(category = nil)
|
|
@category = category if category
|
|
@category || "No category"
|
|
end
|
|
|
|
def description(description = nil)
|
|
@description = description if description
|
|
@description || "No description provided."
|
|
end
|
|
|
|
def help_message(help_message = nil)
|
|
@help_message = help_message if help_message
|
|
@help_message
|
|
end
|
|
|
|
private
|
|
|
|
def highlight(text)
|
|
Color.colorize(text, [:BOLD, :BLUE])
|
|
end
|
|
end
|
|
|
|
def self.execute(irb_context, arg)
|
|
new(irb_context).execute(arg)
|
|
rescue CommandArgumentError => e
|
|
puts e.message
|
|
end
|
|
|
|
def initialize(irb_context)
|
|
@irb_context = irb_context
|
|
end
|
|
|
|
attr_reader :irb_context
|
|
|
|
def execute(arg)
|
|
#nop
|
|
end
|
|
end
|
|
|
|
Nop = Base
|
|
end
|
|
|
|
# :startdoc:
|
|
end
|