Class: Pups::Cli

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

Class Method Summary collapse

Class Method Details

.run(args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pups/cli.rb', line 7

def self.run(args)
  if args.length != 1
    usage
  end

  Pups.log.info("Loading #{args[0]}")
  if args[0] == "--stdin"
    conf = STDIN.readlines.join
    split = conf.split("_FILE_SEPERATOR_")

    conf = nil
    split.each do |data|
      current = YAML.load(data.strip)
      if conf
        conf = Pups::MergeCommand.deep_merge(conf, current, :merge_arrays)
      else
        conf = current
      end
    end

    config = Pups::Config.new(conf)
  else
    config = Pups::Config.load_file(args[0])
  end
  config.run

ensure
  Pups::ExecCommand.terminate_async
end

.usageObject



3
4
5
6
# File 'lib/pups/cli.rb', line 3

def self.usage
  puts "Usage: pups FILE or pups --stdin"
  exit 1
end