Module: Hawk::CLI

Defined in:
lib/hawk/cli.rb

Defined Under Namespace

Modules: Options

Class Method Summary collapse

Class Method Details

.closest_hawkfile(dir) ⇒ Object



49
50
51
52
53
54
55
56
57
58
# File 'lib/hawk/cli.rb', line 49

def self.closest_hawkfile(dir)
  file_name = File.join(dir, 'Hawkfile')
  if File.exists?(file_name)
    file_name
  elsif dir == '/'
    nil
  else
    closest_hawkfile(File.expand_path(File.join(dir, '..')))
  end
end

.run(args) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/hawk/cli.rb', line 38

def self.run(args)
  options = Options.parse!(ARGV)
  hawkfile = closest_hawkfile(Dir.pwd)
  if (hawkfile)
    Dir.chdir(File.dirname(hawkfile))
    Hawk::DSL.load(hawkfile, options)
  else
    puts "Cannot find hawkfile"
  end
end