summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorAdam Jacob <adam@hjksolutions.com>2008-12-02 02:09:19 -0800
committerAdam Jacob <adam@hjksolutions.com>2008-12-02 02:09:19 -0800
commit69a778d4db0752d111927c560923fda6fbc6c7d7 (patch)
treebcb424bd3a4e756a68b9a0bf7089af17ac4eef25 /bin
parent3a9543f8dbff45b2a393d44ef1c72ede0a26d6af (diff)
downloadohai-69a778d4db0752d111927c560923fda6fbc6c7d7.tar.gz
Ohai lives - first meaningful commit
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ohai27
1 files changed, 24 insertions, 3 deletions
diff --git a/bin/ohai b/bin/ohai
index 35ac641e..4fbad8d4 100755
--- a/bin/ohai
+++ b/bin/ohai
@@ -18,17 +18,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+$: << File.join(File.dirname(__FILE__), "..", "lib")
require 'optparse'
require 'rubygems'
-#require 'ohai'
+require 'ohai'
require 'json'
config = {
+ :directory => nil,
+ :file => nil,
:kthxbye => false
}
opts = OptionParser.new do |opts|
- opts.banner = "Usage: #{$0} [-d DIR|-r FILE] (options)"
+ opts.banner = "Usage: #{$0} (options)"
+ 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("-k", "--kthxbye", "LOLcats") do |k|
config[:kthxbye] = true
end
@@ -41,4 +50,16 @@ opts.parse!(ARGV)
if config[:kthxbye]
puts JSON.generate({ :lolcat => "http://icanhascheezburger.com/?random" })
-end \ No newline at end of file
+end
+
+ohai = Ohai::System.new
+if config[:file]
+ ohai.from_file(config[:file])
+else
+ if config[:directory]
+ Ohai::Config[:plugin_path] << config[:directory]
+ end
+ ohai.all_plugins
+end
+
+puts ohai.json_pretty_print