Class: RubyUIConverter::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


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

def self.exit_on_failure?
  true
end

Instance Method Details

#convert(path) ⇒ Object



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
56
57
58
59
60
61
# File 'lib/ruby_ui_converter/cli.rb', line 31

def convert(path)
  unless File.exist?(path)
    say "Path not found: #{path}", :red
    exit 1
  end

  if options[:root]
    root = File.expand_path(options[:root])
    unless File.directory?(root) && File.expand_path(path).start_with?(root)
      say "Invalid --root: #{options[:root]} (must be an existing ancestor of PATH)", :red
      exit 1
    end
  end

  config = Configuration.new(
    base_namespace: options[:namespace],
    root: options[:root],
    base_class: options[:base_class],
    phlex_version: options[:phlex],
    output_root: options[:output],
    dry_run: options[:dry_run],
    force: options[:force],
    ruby_ui: options[:ruby_ui],
    literal: options[:literal],
    verbose: options[:verbose]
  )

  results = Converter.new(path, config: config).run
  report(results, config)
  check_prerequisites(results, config, path)
end

#versionObject



64
65
66
# File 'lib/ruby_ui_converter/cli.rb', line 64

def version
  say RubyUIConverter::VERSION
end