Class: Transducer::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean



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

def self.exit_on_failure?
  true
end

Instance Method Details

#generate(input_file) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/transducer/cli.rb', line 16

def generate(input_file)
  unless File.exist?(input_file)
    error "Input file not found: #{input_file}"
    exit 1
  end

  output_file = options[:output]
  template_path = options[:template]

  parser = Parser.new(input_file)
  data = parser.parse

  generator = Generator.new(data, template_path: template_path)
  generator.to_file(output_file)

  success "Documentation generated successfully: #{output_file}"
rescue FileError => e
  error "File error: #{e.message}"
  exit 1
rescue ParseError => e
  error "Parse error: #{e.message}"
  exit 2
rescue ValidationError => e
  error "Validation error: #{e.message}"
  exit 3
rescue StandardError => e
  error "Unexpected error: #{e.message}"
  exit 4
end

#versionObject



47
48
49
# File 'lib/transducer/cli.rb', line 47

def version
  puts "Transducer version #{Transducer::VERSION}"
end