Class: Chusaku::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/chusaku/cli.rb

Overview

Enables flags for the ‘chusaku` executable.

Constant Summary collapse

STATUS_SUCCESS =
0
STATUS_ERROR =
1
Finished =
Class.new(RuntimeError)
NotARailsProject =
Class.new(RuntimeError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChusaku::CLI

Initializes a new instance of ‘Chusaku::CLI`.



18
19
20
# File 'lib/chusaku/cli.rb', line 18

def initialize
  @options = {}
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/chusaku/cli.rb', line 7

def options
  @options
end

Instance Method Details

#call(args = ARGV) ⇒ Integer

Parse CLI flags, if any, and handle applicable behaviors.

Parameters:

  • args (Array<String>) (defaults to: ARGV)

    CLI arguments

Returns:

  • (Integer)

    0 on success, 1 on error



26
27
28
29
30
31
32
33
34
35
# File 'lib/chusaku/cli.rb', line 26

def call(args = ARGV)
  optparser.parse!(args)
  check_for_rails_project
  Chusaku.call(options)
rescue NotARailsProject
  warn("Please run chusaku from the root of your project.")
  STATUS_ERROR
rescue Finished
  STATUS_SUCCESS
end