class Matrixeval::CommandLine::ParseInitArguments

Attributes

init_arguments[R]
options[R]

Public Class Methods

call(arguments) click to toggle source
# File lib/matrixeval/command_line/parse_init_arguments.rb, line 5
def call(arguments)
  new(arguments).call
end
new(init_arguments) click to toggle source
# File lib/matrixeval/command_line/parse_init_arguments.rb, line 12
def initialize(init_arguments)
  @init_arguments = init_arguments
  @options = {}
end

Public Instance Methods

call() click to toggle source
# File lib/matrixeval/command_line/parse_init_arguments.rb, line 17
def call
  parse!
  options
end

Private Instance Methods

parse!() click to toggle source
# File lib/matrixeval/command_line/parse_init_arguments.rb, line 24
      def parse!
        OptionParser.new do |opts|
          opts.version = Matrixeval::VERSION
          opts.program_name = ""
          opts.banner = <<~USAGE
            Usage:
                matrixeval(meval) init [Options]
            USAGE

          opts.separator ""
          opts.separator "Options:"
          opts.on("-t", "--target [TARGET]", *[
            "# Initialize with a specific target",
            "# Options: #{Matrixeval.targets.keys}",
            "# Default: none"
          ])

          opts.on("-h", "--help", "# Show help") do
            puts opts.help
            exit
          end
        end.parse!(init_arguments, into: options)
      end