Class: Mutant::CLI

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Flat
Defined in:
lib/mutant/cli.rb

Overview

Commandline parser

Constant Summary collapse

Error =

Error failed when CLI argv is invalid

Class.new(RuntimeError)
EXIT_FAILURE =
1
EXIT_SUCCESS =
0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arguments) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize objecct



39
40
41
42
43
# File 'lib/mutant/cli.rb', line 39

def initialize(arguments)
  @config = Config::DEFAULT

  parse(arguments)
end

Instance Attribute Details

#configConfig (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return config



51
52
53
# File 'lib/mutant/cli.rb', line 51

def config
  @config
end

Class Method Details

.run(arguments) ⇒ Fixnum

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run cli with arguments



24
25
26
27
28
29
# File 'lib/mutant/cli.rb', line 24

def self.run(arguments)
  Env.call(call(arguments)).success? ? EXIT_SUCCESS : EXIT_FAILURE
rescue Error => exception
  $stderr.puts(exception.message)
  EXIT_FAILURE
end