Sha256: 4c22ecf8985bb678900bcd5dee0a1da8103638c6245d1237ce2ddb8e670c1670

Contents?: true

Size: 839 Bytes

Versions: 16

Compression:

Stored size: 839 Bytes

Contents

# encoding: utf-8

module GithubCLI
  class Command
    # Makes it easy to parse required and options arguments.
    class Arguments

      SEPARATOR = '/'

      attr_reader :args

      def initialize(args)
        @args = args
      end

      # Returns seperated arguments
      def parse
        required, non_required = nil, nil

        if !args.empty?
          required = args
          non_required, required = required.split('/', 2) if required.index('/')
        else
          raise RequiredArgumentMissingError, "No value provided for required argument"
        end
        [non_required, required]
      end

      # Returns a concise string representation of Arguments instance
      #
      def inspect
        "#<#{self.class.inspect} @args=#{args.inspect}"
      end

    end # Arguments
  end # Command
end # GithubCLI

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
github_cli-0.6.2 lib/github_cli/command/arguments.rb
github_cli-0.6.1 lib/github_cli/command/arguments.rb
github_cli-0.6.0 lib/github_cli/command/arguments.rb
github_cli-0.5.9 lib/github_cli/command/arguments.rb
github_cli-0.5.8 lib/github_cli/command/arguments.rb
github_cli-0.5.7 lib/github_cli/command/arguments.rb
github_cli-0.5.6 lib/github_cli/command/arguments.rb
github_cli-0.5.5 lib/github_cli/command/arguments.rb
github_cli-0.5.4 lib/github_cli/command/arguments.rb
github_cli-0.5.3 lib/github_cli/command/arguments.rb
github_cli-0.5.2 lib/github_cli/command/arguments.rb
github_cli-0.5.1 lib/github_cli/command/arguments.rb
github_cli-0.5.0 lib/github_cli/command/arguments.rb
github_cli-0.4.4 lib/github_cli/command/arguments.rb
github_cli-0.4.3 lib/github_cli/command/arguments.rb
github_cli-0.4.2 lib/github_cli/command/arguments.rb