Module: Hawk::CLI

Defined in:
lib/hawk/cli.rb

Class Method Summary collapse

Class Method Details

.closest_hawkfile(dir) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/hawk/cli.rb', line 13

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



3
4
5
6
7
8
9
10
11
# File 'lib/hawk/cli.rb', line 3

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