#!/usr/bin/env ruby require 'rubygems' $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))) require 'chef_zero/version' require 'chef_zero/server' require 'optparse' options = {} OptionParser.new do |opts| opts.banner = "Usage: chef-zero [ARGS]" opts.on("-H", "--host HOST", "Host to bind to (default: 127.0.0.1)") do |value| options[:host] = value end opts.on("-p", "--port PORT", Integer, "Port to listen on") do |value| options[:port] = value end opts.on("--[no-]generate-keys", "Whether to generate actual keys or fake it (faster). Default: false.") do |value| options[:generate_real_keys] = value end opts.on("-d", "--daemon", "Run as a daemon process") do |value| options[:daemon] = value end opts.on("-l", "--log-level LEVEL", "Set the output log level") do |value| options[:log_level] = value end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.on_tail("--version", "Show version") do puts ChefZero::VERSION exit end end.parse! server = ChefZero::Server.new(options) if options[:daemon] unless Process.respond_to?('daemon') abort 'Process.deamon requires Ruby >= 1.9' else Process.daemon(true) server.start(:publish => true) end else server.start(:publish => true) end