Class: Logchange::Dispatch

Inherits:
Object
  • Object
show all
Defined in:
lib/logchange/dispatch.rb

Overview

Routes the user’s command to appropriate handler.

Instance Method Summary collapse

Instance Method Details

#executeObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/logchange/dispatch.rb', line 4

def execute
  ensure_changelog_directory_exists if %i[new release].include?(command)

  case command
    when :init
      Logchange::Initialize.new.execute
    when :new
      if ARGV[1].nil?
        Logchange::InteractiveLogger.new.execute
      else
        Logchange::Logger.new(ARGV[1]).execute
      end
    when :release
      Logchange::Release.new(ARGV[1]).execute
    else
      print_help
  end
end