forked from emiltin/healing
/
heal
executable file
·42 lines (32 loc) · 890 Bytes
/
heal
1
2
3
4
5
6
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
36
37
38
39
40
41
42
#!/usr/bin/env ruby
require 'rubygems'
require 'trollop'
require File.dirname(__FILE__)+'/../lib/healing'
commands = 'ideal scan terminate heal volumes upload diagnose prune'.split
matches = commands.select { |c| c.match /^#{ARGV[0]}/ }
if matches.size==1
ARGV[0] = matches.first
end
parser = nil
opts = Trollop::options do
parser = self
stop_on commands
opt :version, "show version"
version "Healing 0.1.0" #TODO should fetch this from a yaml file, so we don't forget to update it
banner "\nHealing is a cloud configuration system."
end
if matches.size>1
puts "Which command? #{matches.join(', ')}"
exit
end
cmd = ARGV[0]
unless cmd && commands.include?(cmd)
puts "Usage:\n\theal <command> <options>\n\n"
puts "Commands:"
puts commands.map {|c| "\t#{c}\n" }
exit
end
#run subcommand:
cmd = ARGV.shift
path = Healing::BASE+'/bin/heal-'+cmd
load path