Sha256: 572b7be2c313167b380768f65c643351ee5661a777c87c5a5eaafe3b4bf485e9
Contents?: true
Size: 1.03 KB
Versions: 6
Compression:
Stored size: 1.03 KB
Contents
module Rootage # `Argument` is an argument item for command. class Argument < Item # Normalization type. member :type # Name at heading in help. member :heading # The message to show if the argument is missing member :missing def validate(&b) self.validator = b end end module ArgumentCollection include CollectionInterface set_item_class Argument end class ArgumentDefinition < Sequence include CollectionInterface set_item_class Argument private # Parse the argument. # # @param cmd [Command] # command object # @return [void] def execute_main(cmd) list.each_with_index do |item, i| if cmd.argv[i].nil? if item.missing raise ArgvError.new(item.missing) else raise ArgvError.new("The argument <%{name}> required." % {name: item.heading || item.name}) end else cmd.model[item.key] = Normalizer.normalize(item.type, cmd.argv[i]) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems