Class: YamlRefResolver::CLI

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

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



8
9
10
11
12
13
14
15
16
# File 'lib/yaml_ref_resolver/cli.rb', line 8

def initialize
  @opt = OptionParser.new
  @input = nil
  @output = nil
  @watch = false
  @json = false

  define_options
end

Instance Method Details

#run(argv) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/yaml_ref_resolver/cli.rb', line 18

def run(argv)
  @opt.parse!(argv)
  validate_input_path

  if @watch
    resolve_and_dump
    FileWatcher.new(resolver.files).watch do |filename|
      resolve_and_dump(File.expand_path filename)
    end
  else
    exit(1) unless resolve_and_dump
  end
end