Class Clio::Usage::Parser
In: lib/clio/usage/parser.rb
Parent: Object

Parser

Parse commandline arguments according to given Usage.

Methods

errors   inspect   key   name   new   parse   parse_errors   parsed?  

Attributes

argv  [R] 
signatures  [R] 
usage  [R] 

Public Class methods

[Source]

# File lib/clio/usage/parser.rb, line 20
      def initialize(usage, argv) #, index=0)
        # convert to array if argv string
        if ::String===argv
          argv = Shellwords.shellwords(argv)
        else
          argv = argv.dup
        end

        @usage  = usage
        @argv   = argv

        @parsed     = false
        @signatures = []
        @errors     = []
      end

Public Instance methods

[Source]

# File lib/clio/usage/parser.rb, line 175
      def errors
        @errors
      end

[Source]

# File lib/clio/usage/parser.rb, line 41
      def inspect
        s = "<" + signatures.inspect + ">"
        s
        #s  = "#<#{self.class}"
        #s << " @options=#{@options.inspect}" unless @options.empty?
        #s << " @arguments=#{@arguments.inspect}" unless @arguments.empty?
        #s << " @subcommand=#{@subcommand}>" if @subcommand
        #s << ">"
        #s
      end

[Source]

# File lib/clio/usage/parser.rb, line 38
      def key  ; usage.key  ; end

[Source]

# File lib/clio/usage/parser.rb, line 37
      def name ; usage.name ; end

[Source]

# File lib/clio/usage/parser.rb, line 53
      def parse
        @parsed     = false
        @signatures = []
        @errors     = []

        parse_command(usage, argv.dup)

        @parsed     = true

        return Interface.new(@signatures, @errors)
      end
parse_errors()

Alias for errors

Has the commandline been parsed?

[Source]

# File lib/clio/usage/parser.rb, line 66
      def parsed? ; @parsed ; end

[Validate]