summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoser, Kevin <Kevin.Moser@nordstrom.com>2013-03-13 12:47:19 -0700
committerMoser, Kevin <Kevin.Moser@nordstrom.com>2013-03-13 12:47:19 -0700
commit9ba15865d7080e423ece5f418c37f512c1118727 (patch)
tree1ab8c33e53d655312a4080f7dc4b91a8fe4c0a36
parentc98695c6abf3384ae823a991d991151d92d5720f (diff)
downloadmixlib-shellout-9ba15865d7080e423ece5f418c37f512c1118727.tar.gz
Add option validation
-rw-r--r--lib/mixlib/shellout.rb6
-rw-r--r--lib/mixlib/shellout/unix.rb5
-rw-r--r--lib/mixlib/shellout/windows.rb9
3 files changed, 19 insertions, 1 deletions
diff --git a/lib/mixlib/shellout.rb b/lib/mixlib/shellout.rb
index 5b50a14..63744f1 100644
--- a/lib/mixlib/shellout.rb
+++ b/lib/mixlib/shellout.rb
@@ -296,8 +296,12 @@ module Mixlib
raise InvalidCommandOption, "option '#{option.inspect}' is not a valid option for #{self.class.name}"
end
end
- end
+ validate_options(opts)
+ end
+ def validate_options(opts)
+ super
+ end
end
end
diff --git a/lib/mixlib/shellout/unix.rb b/lib/mixlib/shellout/unix.rb
index a983e05..776169d 100644
--- a/lib/mixlib/shellout/unix.rb
+++ b/lib/mixlib/shellout/unix.rb
@@ -20,6 +20,11 @@ module Mixlib
class ShellOut
module Unix
+ # Option validation that is unix specific
+ def validate_options(opts)
+ # No options to validate, raise exceptions here if needed
+ end
+
# Run the command, writing the command's standard out and standard error
# to +stdout+ and +stderr+, and saving its exit status object to +status+
# === Returns
diff --git a/lib/mixlib/shellout/windows.rb b/lib/mixlib/shellout/windows.rb
index 5fe9667..3251f66 100644
--- a/lib/mixlib/shellout/windows.rb
+++ b/lib/mixlib/shellout/windows.rb
@@ -35,6 +35,15 @@ module Mixlib
TIME_SLICE = 0.05
+ # Option validation that is windows specific
+ def validate_options(opts)
+ if opts["user"]
+ unless opts["password"] && opts["domain"]
+ raise InvalidCommandOption, "You must supply both a username and password when supplying a user in windows"
+ end
+ end
+ end
+
#--
# Missing lots of features from the UNIX version, such as
# uid, etc.