diff options
author | Tim Smith <tsmith@chef.io> | 2018-07-06 19:31:12 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-07-06 19:31:12 -0700 |
commit | 4d257e6d606d393a70d7bffce0747aa2e1f3389d (patch) | |
tree | 7976d151c6e9bde4f7f0c8a292db8b816d3d2b75 | |
parent | c8d07d3389f1127e0ac17a7288d883b5b8974d8a (diff) | |
download | ohai-4d257e6d606d393a70d7bffce0747aa2e1f3389d.tar.gz |
Allow passing more than one directory on the CLI
It's easy enough to split the directory on a comma
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/ohai/application.rb | 9 | ||||
-rw-r--r-- | lib/ohai/system.rb | 9 |
2 files changed, 13 insertions, 5 deletions
diff --git a/lib/ohai/application.rb b/lib/ohai/application.rb index 0e991aa8..f64f9e97 100644 --- a/lib/ohai/application.rb +++ b/lib/ohai/application.rb @@ -34,8 +34,13 @@ class Ohai::Application option :directory, short: "-d DIRECTORY", long: "--directory DIRECTORY", - description: "A directory to add to the Ohai plugin search path", - proc: lambda { |path| Ohai::Config.platform_specific_path(path) } + description: "A directory to add to the Ohai plugin search path. If passing multiple directories comma separate directories.", + proc: lambda { |paths| + paths = paths.split(",") + paths.map do |path| + Ohai::Config.platform_specific_path(path) + end + } option :log_level, short: "-l LEVEL", diff --git a/lib/ohai/system.rb b/lib/ohai/system.rb index b3a2dfc3..f13d89e4 100644 --- a/lib/ohai/system.rb +++ b/lib/ohai/system.rb @@ -176,9 +176,12 @@ module Ohai def configure_ohai Ohai.config.merge!(@config) - if Ohai.config[:directory] && - !Ohai.config[:plugin_path].include?(Ohai.config[:directory]) - Ohai.config[:plugin_path] << Ohai.config[:directory] + # add any additional CLI passed directories to the plugin path excluding duplicates + unless Ohai.config[:directory].nil? + Ohai.config[:directory].each do |dir| + next if Ohai.config[:plugin_path].include?(dir) + Ohai.config[:plugin_path] << dir + end end logger.debug("Running Ohai with the following configuration: #{Ohai.config.configuration}") |