summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMathieu Sauve-Frankel <msf@kisoku.net>2009-09-08 17:52:43 +0900
committerAJ Christensen <aj@junglist.gen.nz>2009-10-02 17:37:25 +1300
commit85c5f9d5bbb7ed73894a570a83716e8424dd76de (patch)
tree16e5bd9451a015622282c85df4ac6710c26949b7 /bin
parent6f2a3620474004ee3cfe4f476dda777aefd5add0 (diff)
downloadohai-85c5f9d5bbb7ed73894a570a83716e8424dd76de.tar.gz
refactor ohai to use mixlib
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ohai57
1 files changed, 3 insertions, 54 deletions
diff --git a/bin/ohai b/bin/ohai
index d6593d26..f502c000 100755
--- a/bin/ohai
+++ b/bin/ohai
@@ -20,59 +20,8 @@
#
$: << File.join(File.dirname(__FILE__), "..", "lib")
-require 'optparse'
-require 'rubygems'
-require 'ohai'
-require 'json'
-
-config = {
- :directory => nil,
- :file => nil,
- :log_level => :info
-}
-
-opts = OptionParser.new do |opts|
- opts.banner = "Usage: #{$0} (options) [attributes]"
- opts.on("-d", "--directory NAME", "A directory to add to the Ohai search path") do |d|
- config[:directory] = d
- end
- opts.on("-f", "--file NAME", "A file to run Ohai against") do |f|
- config[:file] = f
- end
- opts.on("-l", "--loglevel NAME", "Set log level for Ohai") do |l|
- config[:log_level] = l.to_sym
- end
- opts.on("-v", "--version", "Display Ohai version") do |v|
- puts "Ohai, version #{::Ohai::VERSION}"
- exit
- end
- opts.on_tail("-h", "--help", "Show this message") do
- puts opts
- puts "\n [attributes] is a space-separated list of top-level attributes to display (JSON)."
- exit
- end
-end
-attributes = opts.parse(ARGV)
-
-ohai = Ohai::System.new
-
-if [ :debug, :info, :warn, :error, :fatal ].include?(config[:log_level])
- Ohai::Config[:log_level] = config[:log_level]
-end
-if config[:file]
- ohai.from_file(config[:file])
-else
- if config[:directory]
- Ohai::Config[:plugin_path] << config[:directory]
- end
- ohai.all_plugins
-end
+require 'rubygems'
+require 'ohai/application'
-if attributes.length > 0
- attributes.each do |a|
- puts ohai.attributes_print(a)
- end
-else
- puts ohai.json_pretty_print
-end \ No newline at end of file
+Ohai::Application.new.run