class Arcanus::CLI
Command
line application interface.
Public Class Methods
new(input:, output:)
click to toggle source
Create a CLI
that outputs to the given output destination.
@param input [Arcanus::Input] @param output [Arcanus::Output]
# File lib/arcanus/cli.rb, line 21 def initialize(input:, output:) @ui = UI.new(input, output) end
Public Instance Methods
run(arguments)
click to toggle source
Parses the given command-line arguments and executes appropriate logic based on those arguments.
@param [Array<String>] arguments @return [Integer] exit status code
# File lib/arcanus/cli.rb, line 30 def run(arguments) run_command(arguments) ExitCodes::OK rescue => ex ErrorHandler.new(@ui).handle(ex) end
Private Instance Methods
convert_arguments(arguments)
click to toggle source
# File lib/arcanus/cli.rb, line 52 def convert_arguments(arguments) # Display all open changes by default return ['help'] if arguments.empty? # TODO: Evaluate repo and recommend next step return ['help'] if %w[-h --help].include?(arguments.first) return ['version'] if %w[-v --version].include?(arguments.first) arguments end
run_command(arguments)
click to toggle source
Executes the appropriate command given the list of command line arguments.
@param ui [Arcanus::UI] @param arguments [Array<String>] @raise [Arcanus::Errors::ArcanusError] when any exceptional circumstance occurs
# File lib/arcanus/cli.rb, line 45 def run_command(arguments) arguments = convert_arguments(arguments) require 'arcanus/command/base' Command::Base.from_arguments(@ui, arguments).run end