class MxxRu::Generators::Impl::Cpp::Options

Class for storing command-line arguments as options.

Usage:

options = Options.parse( args, banner, { :implib_path => false } )

Attributes

implib_path[RW]

Name of import library path (–implib-path).

output_file[RW]

Name of output file (-o, –output-file). nil if missing.

project_path[RW]

Project path (name of project directory in cmd-line).

target_name[RW]

Name of target (-t, –target).

Public Class Methods

parse( args, banner, params ) click to toggle source

Parsing command-line arguments and returning Options instance.

These keys are supported in params:

implib_path

true or false. Enables/disables argument –implib-path.

Calls exit(1) if –help present in args.

# File lib/mxx_ru/generators/impl/cpp/generation.rb, line 81
def Options.parse( args, banner, params )
  parser = OptionParser.new

  result = Options.new

  parser.banner = banner

  parser.on( '-t', '--target NAME', 'Target name' ) do |p|
    result.target_name = p
  end

  parser.on( '-o', '--output-file FILE', 'Output file name' ) do |p|
    result.output_file = p
  end

  if true == params.fetch( :implib_path, false ) 
    parser.on( '--implib-path PATH', 'Import library path name' ) do |p|
      result.implib_path = p
    end
  end

  parser.on_tail( '-h', '--help', 'Show this message' ) do
    puts parser
    exit(1)
  end

  parser.order!( args ) do |noarg|
    # Any non-options is considered as project path name.
    result.project_path = noarg
  end

  result
end