Sha256: 8d5b04d47d95b788c765c23b4e2109344bb55f607a643dcaed9ee5cd1a82c006

Contents?: true

Size: 912 Bytes

Versions: 3

Compression:

Stored size: 912 Bytes

Contents

#!/usr/bin/env ruby

$LOAD_PATH << File.expand_path("../../lib", __FILE__)

require 'hieracles'
require 'hieracles/options/hc'

opt = Hieracles::Options::Hc.new(ARGV)

if opt.options.has_key? :version
  puts Hieracles.version
  exit(0)
end

fqdn = opt.payload[0]
command = opt.payload[1]
args = opt.payload[2..-1]

unless fqdn && command
  puts Hieracles::Options::Hc.usage
  exit(1)
end
 
if Hieracles::Format.method_defined? command
  begin
    node = Hieracles::Node.new fqdn, opt.options
  rescue Exception => e
    puts "*** Error: #{e.message}"
    exit(1)
  end
  begin
    formatter = Object.const_get("Hieracles::Formats::#{Hieracles::Config.format}")
  rescue
    puts "*** Unknown format #{Hieracles::Config.format}"
    exit(1)
  end
  dispatch = formatter.new node
  puts dispatch.send(command.to_sym, args)
else
  puts "*** Unknown command: #{command}"
  Hieracles::Options::Hc.usage
  exit(1)
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hieracles-0.3.0 bin/hc
hieracles-0.2.2 bin/hc
hieracles-0.2.1 bin/hc