Class: QAT::CLI::Main

Inherits:
Object
  • Object
show all
Includes:
Generator
Defined in:
lib/qat/cli/main.rb

Overview

Main class for the CLI.

Since:

  • 0.1.0

Instance Method Summary collapse

Methods included from Generator

#add_module, #add_modules, #create_project

Constructor Details

#initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ Main

Initialization from command line

Since:

  • 0.1.0



14
15
16
17
18
19
# File 'lib/qat/cli/main.rb', line 14

def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)
  @argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
  @options                                 = {}
  @sub_options                             = {}
  @exit_code                               = 0
end

Instance Method Details

#execute!Object

Main entry point for execution

Since:

  • 0.1.0



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/qat/cli/main.rb', line 22

def execute!
  parse_argv!

  handle_options if @options.any?

rescue ArgumentError, OptionParser::MissingArgument => exception
  @stderr.puts "Error: #{exception.message}"
  @exit_code = 1
ensure
  @kernel.exit(exit_code)
end