Sha256: c9c27babf26354434820286f9630e1a99197de8b9c72dc8c5cd972df4d80931a

Contents?: true

Size: 1.91 KB

Versions: 2

Compression:

Stored size: 1.91 KB

Contents

#!/usr/bin/env ruby

require 'rubygems'
require 'sermont'
require 'fileutils'
require 'yaml'

if ARGV.empty?
  Sermont.new.run
elsif ARGV.include?("--help") || ARGV.include?("-h")
  help = <<-HELP
Usage: sermont [options]
Options:

  --setup               : copy example config file to your home directory
  -r,  --raw            : print the report without colors
  -t TIME, --time TIME  : checking every TIME seconds
  -o FILE, --output FILE: write the report to the FILE
  -d, --daemon          : running as a daemon
  -h, --help            : print this help
  -v, --version         : print sermont version

Example:

  sermont -r -o /var/log/sermont.log -d -t 1800

Sermont by xinuc, http://github.com/xinuc/sermont
  HELP
  
  puts(help)
elsif ARGV.include?("--version") || ARGV.include?("-v")
  config = YAML.load(File.read(File.dirname(__FILE__) + '/../' + 'VERSION.yml'))
  version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
  puts "Sermont : version #{version}"
  puts "Sermont by xinuc, http://github.com/xinuc/sermont"
elsif ARGV.include?("--setup")
  FileUtils.cp(File.expand_path(File.dirname(__FILE__) + "/../lib/config/sermont.yaml"), File.expand_path("~/.sermont.yml"))
  FileUtils.mkdir(File.expand_path("~/.sermont")) unless File.exists?(File.expand_path("~/.sermont"))
  puts "Creating #{File.expand_path("~/.sermont")} directory."
  puts "Copying .sermont.yml to your home directory."
  puts "Please edit this file according to your servers."
else
  raw, time, out, daemon = nil
  raw = ARGV.include?("--raw") || ARGV.include?("-r")
  if ARGV.include?("-t")  || ARGV.include?("--time")
    t_index = ARGV.index("-t") || ARGV.index("--time")
    time = ARGV[t_index + 1]
  end
  if ARGV.include?("-o") || ARGV.include?("--output")
    o_index = ARGV.index("-o") || ARGV.index("--output")
    out = ARGV[o_index + 1]
  end
  daemon = ARGV.include?("--daemon") || ARGV.include?("-d")
  Sermont.new.run(raw, time, out, daemon)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
xinuc-sermont-0.2.5 bin/sermont
xinuc-sermont-0.2.6 bin/sermont