Sha256: 0dd77f229114e7c7fe2101e46e75ea60a6c8ada87a08dcc6efde23d0531092c5

Contents?: true

Size: 932 Bytes

Versions: 5

Compression:

Stored size: 932 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
    config = Hieracles::Config.new opt.options
    node = Hieracles::Node.new fqdn, config
  rescue Exception => e
    puts "*** Error: #{e.message}"
    exit(1)
  end
  begin
    formatter = Object.const_get("Hieracles::Formats::#{config.format}")
  rescue
    puts "*** Unknown format #{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

5 entries across 5 versions & 1 rubygems

Version Path
hieracles-0.3.5 bin/hc
hieracles-0.3.4 bin/hc
hieracles-0.3.3 bin/hc
hieracles-0.3.2 bin/hc
hieracles-0.3.1 bin/hc