lib/inch/cli/command_parser.rb in inch-0.7.1 vs lib/inch/cli/command_parser.rb in inch-0.8.0.rc1
- old
+ new
@@ -32,10 +32,15 @@
# The +--help+ switch is an exception and lists all available commands.
#
class CommandParser
include TraceHelper
+ # Represents a fake command, i.e. `--help` for use in the CLI.
+ #
+ # @api private
+ FakeCommand = Struct.new(:exit_status)
+
class << self
# @return [Hash{Symbol => Command}] the mapping of command names to
# command classes to parse the user command.
attr_accessor :commands
@@ -75,10 +80,10 @@
ui.trace 'Commands:'
commands.keys.sort_by { |k| k.to_s }.each do |command_name|
command = commands[command_name].new
ui.trace format(' %-8s %s', command_name, command.description)
end
- exit 0
+ FakeCommand.new(0)
end
# Runs the {Command} object matching the command name of the first
# argument.
# @return [Command::Base]