lib/como.rb in como-0.2.1 vs lib/como.rb in como-0.2.2

- old
+ new

@@ -693,12 +693,13 @@ # Overlay user config on top of default. subcmd.applyConfig( config ) if subcmd.config[ :autohelp ] - # Automatically add the help option. - defs.insert( 0, [ :silent, "help", "-h", "Display usage info." ] ) + # Automatically add the help option and make it also mutex. + spec = MAP_TYPE_PRIMS[ :silent ] + [ :mutex ] + defs.insert( 0, [ spec, "help", "-h", "Display usage info." ] ) end Spec.specify( subcmd, defs ) end @@ -799,27 +800,31 @@ # Hidden option (no usage doc). :hidden ] + MAP_TYPE_PRIMS = { + :switch => [ :none, :opt ], + :single => [ :one ], + :multi => [ :one, :many ], + :opt_single => [ :one, :opt ], + :opt_multi => [ :one, :many, :opt ], + :opt_any => [ :none, :one, :many, :opt ], + :default => [ :none, :one, :many, :opt, :default ], + :exclusive => [ :none, :one, :many, :opt, :mutex ], + :silent => [ :none, :opt, :hidden ], + } + + # Convert option types (type definitions) to option type # primitives. def Spec.mapTypeToPrims( type ) prims = nil if type.kind_of? Symbol - case type - when :switch; prims = [ :none, :opt ] - when :single; prims = [ :one ] - when :multi; prims = [ :one, :many ] - when :opt_single; prims = [ :one, :opt ] - when :opt_multi; prims = [ :one, :many, :opt ] - when :opt_any; prims = [ :none, :one, :many, :opt ] - when :default; prims = [ :none, :one, :many, :opt, :default ] - when :exclusive; prims = [ :none, :one, :many, :opt, :mutex ] - when :silent; prims = [ :none, :opt, :hidden ] - else + prims = MAP_TYPE_PRIMS[ type ] + unless prims raise "Unknown option type: \"#{type}\"..." end elsif type.kind_of? Array prims = []