Sha256: bcc28950e777fb12451b359839be8eefa464cca6db5cc595a11089dc1ca5d792

Contents?: true

Size: 633 Bytes

Versions: 3

Compression:

Stored size: 633 Bytes

Contents

module Anvil
  class Parser < OptionParser
    attr_accessor :options
    attr_accessor :task

    def options
      @options ||= {}
    end

    def arguments(args = [])
      @arguments ||= []
      @arguments += args if args.any?
      @arguments.compact
    end

    def banner
      unless @banner
        @banner = banner_string
        visit(:add_banner, @banner)
      end

      @banner
    end

    def banner_string
      args = arguments.map(&:upcase).join(' ')
      message = "Usage: anvil #{task.task_name}"
      message += " #{args}" unless args.empty?
      message += ' [options]'

      message
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
anvil-core-0.0.1.pre.alpha.3 lib/anvil/parser.rb
anvil-core-0.0.1.pre.alpha.2 lib/anvil/parser.rb
anvil-core-0.0.1.alpha.1 lib/anvil/parser.rb