summaryrefslogtreecommitdiff
path: root/lib/slop/option.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/slop/option.rb')
-rw-r--r--lib/slop/option.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/slop/option.rb b/lib/slop/option.rb
index b8533ae..093b37f 100644
--- a/lib/slop/option.rb
+++ b/lib/slop/option.rb
@@ -4,6 +4,7 @@ module Slop
help: true,
tail: false,
underscore_flags: true,
+ required: false,
}
# An Array of flags this option matches.
@@ -101,6 +102,11 @@ module Slop
config[:suppress_errors]
end
+ # Returns true if an exception should be raised when this option isn't supplied.
+ def required?
+ config[:required]
+ end
+
# Returns all flags joined by a comma. Used by the help string.
def flag
flags.join(", ")