Class: MtTool::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/mt_tool/commands.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CLI

Returns a new instance of CLI.



9
10
11
12
13
14
15
16
# File 'lib/mt_tool/commands.rb', line 9

def initialize(*args)
  super
  @logger = Logger.new(STDOUT)
  @logger.level = Logger::DEBUG
  @logger.formatter = proc do |severity, datetime, progname, msg|
    "[#{severity}][#{datetime.strftime('%Y-%m-%d %H:%M:%S.%L')}] #{msg}\n"
  end
end

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/mt_tool/commands.rb', line 18

def self.exit_on_failure?
  true
end

Instance Method Details

#vmodObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/mt_tool/commands.rb', line 26

def vmod
  name = options[:name]
  author = options[:author]
  path = options[:path]

  @logger.debug "====== VIPER Module Generation Started ======"
  @logger.debug "Command Parameters:"
  @logger.debug "  - Module name: #{name}"
  @logger.debug "  - Author: #{author}"
  @logger.debug "  - Path: #{path}"
  @logger.debug "Thor Options: #{options.inspect}"
  @logger.debug "Thor Arguments: #{args.inspect}"

  begin
    @logger.debug "Creating new Module instance..."
    module_instance = Module.new(self.args, self.options)
    
    @logger.debug "Calling create_viper_module..."
    module_instance.create_viper_module(path, name, "swift", "", author)
    
    @logger.info "Successfully generated VIPER module: #{name}"
    @logger.debug "====== VIPER Module Generation Completed ======"
  rescue => e
    @logger.error "Failed to generate VIPER module: #{e.message}"
    @logger.debug "Error backtrace:"
    @logger.debug e.backtrace.join("\n")
    @logger.debug "====== VIPER Module Generation Failed ======"
    raise e
  end
end