diff options
author | José Valim <jose.valim@gmail.com> | 2009-07-15 16:20:48 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-07-15 16:20:48 +0200 |
commit | 7022b58842ec3490d85efc5b947d86a0fd72d0cb (patch) | |
tree | ad1134b23961e64f6f754863f82dfeb2e3e0c8b2 /railties/lib/vendor | |
parent | 0702e04e0d671227259f71f614adfe3f35f88b48 (diff) | |
download | rails-7022b58842ec3490d85efc5b947d86a0fd72d0cb.tar.gz rails-7022b58842ec3490d85efc5b947d86a0fd72d0cb.tar.bz2 rails-7022b58842ec3490d85efc5b947d86a0fd72d0cb.zip |
Allow namespaced configuration on generators.
Diffstat (limited to 'railties/lib/vendor')
-rw-r--r-- | railties/lib/vendor/thor-0.11.1/lib/thor/parser/option.rb | 13 | ||||
-rw-r--r-- | railties/lib/vendor/thor-0.11.1/lib/thor/parser/options.rb | 13 |
2 files changed, 20 insertions, 6 deletions
diff --git a/railties/lib/vendor/thor-0.11.1/lib/thor/parser/option.rb b/railties/lib/vendor/thor-0.11.1/lib/thor/parser/option.rb index ab9be6fb9f..5c43f6b18f 100644 --- a/railties/lib/vendor/thor-0.11.1/lib/thor/parser/option.rb +++ b/railties/lib/vendor/thor-0.11.1/lib/thor/parser/option.rb @@ -95,14 +95,21 @@ class Thor end end - def input_required? - type != :boolean + # Allow some type predicates as: boolean?, string? and etc. + # + def method_missing(method, *args, &block) + given = method.to_s.sub(/\?$/, '').to_sym + if valid_type?(given) + self.type == given + else + super + end end protected def validate! - raise ArgumentError, "An option cannot be boolean and required." if type == :boolean && required? + raise ArgumentError, "An option cannot be boolean and required." if boolean? && required? end def valid_type?(type) diff --git a/railties/lib/vendor/thor-0.11.1/lib/thor/parser/options.rb b/railties/lib/vendor/thor-0.11.1/lib/thor/parser/options.rb index 29f6500d97..01c86b7b27 100644 --- a/railties/lib/vendor/thor-0.11.1/lib/thor/parser/options.rb +++ b/railties/lib/vendor/thor-0.11.1/lib/thor/parser/options.rb @@ -122,9 +122,16 @@ class Thor # Parse the value at the peek analyzing if it requires an input or not. # def parse_peek(switch, option) - if option.input_required? - return nil if no_or_skip?(switch) - raise MalformattedArgumentError, "no value provided for option '#{switch}'" unless current_is_value? + unless current_is_value? + if option.boolean? + # No problem for boolean types + elsif no_or_skip?(switch) + return nil # User set value to nil + elsif option.string? && !option.required? + return option.human_name # Return the option name + else + raise MalformattedArgumentError, "no value provided for option '#{switch}'" + end end @non_assigned_required.delete(option) |