class Chandler::CLI

Handles constructing and invoking the appropriate chandler command based on command line arguments and options provided by the CLI::Parser. Essentially this is the “router” for the command-line app.

Public Class Methods

new(parser: Chandler::CLI::Parser.new(ARGV)) click to toggle source
# File lib/chandler/cli.rb, line 17
def initialize(parser: Chandler::CLI::Parser.new(ARGV))
  @parser = parser
end

Public Instance Methods

run() click to toggle source
# File lib/chandler/cli.rb, line 21
def run
  command.call
end

Private Instance Methods

command() click to toggle source
# File lib/chandler/cli.rb, line 27
def command # rubocop:disable Metrics/MethodLength
  case (command = args.shift)
  when "push"
    push
  when nil
    error("Please specify a command")
    info(@parser.usage)
    exit(1)
  else
    error("Unrecognized command: #{command}")
    info(@parser.usage)
    exit(1)
  end
end
push() click to toggle source
# File lib/chandler/cli.rb, line 42
def push
  Chandler::Commands::Push.new(
    :tags => args.empty? ? config.git.version_tags : args,
    :config => config
  )
end