Class: Haml::I18n::Extractor::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/haml-i18n-extractor/cli.rb

Defined Under Namespace

Classes: CliError

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ CLI

Returns a new instance of CLI.



6
7
8
9
# File 'lib/haml-i18n-extractor/cli.rb', line 6

def initialize(opts)
  @options = opts || {}
  @prompter = Haml::I18n::Extractor::Prompter.new # may as well
end

Instance Method Details

#startObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/haml-i18n-extractor/cli.rb', line 11

def start
  check_interactive_or_not_passed
  if @options[:path]
    check_interactive_or_not_passed
    pth = File.expand_path(@options[:path])

    if File.directory?(pth)
      workflow = Haml::I18n::Extractor::Workflow.new(pth, @options)
      workflow.run
    elsif File.exists?(pth) && @options[:interactive]
      extractor = Haml::I18n::Extractor.new(pth, :type => :overwrite, :interactive => true)
      extractor.run
    elsif File.exists?(pth) && @options[:non_interactive]
      extractor = Haml::I18n::Extractor.new(pth, :type => :overwrite, :interactive => false)
      extractor.run
    end
  end
end