summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-07-06 19:31:12 -0700
committerBryan McLellan <btm@loftninjas.org>2018-08-07 11:05:12 -0400
commit5fc1fe56d5333e8495432d20f310090519b2d93b (patch)
tree92a4f31b078ffa7c6293191b62033359cb680c33
parent7e65f9a7eae6208362e117942dff8a9707d76895 (diff)
downloadohai-5fc1fe56d5333e8495432d20f310090519b2d93b.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.rb9
-rw-r--r--lib/ohai/system.rb9
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}")