Class: MxxRu::Generators::Impl::Cpp::Options
- Inherits:
-
Object
- Object
- MxxRu::Generators::Impl::Cpp::Options
- Defined in:
- lib/mxx_ru/generators/impl/cpp/generation.rb
Overview
Class for storing command-line arguments as options.
Usage:
= Options.parse( args, , { :implib_path => false } )
Instance Attribute Summary collapse
-
#implib_path ⇒ Object
Name of import library path (–implib-path).
-
#output_file ⇒ Object
Name of output file (-o, –output-file).
-
#project_path ⇒ Object
Project path (name of project directory in cmd-line).
-
#target_name ⇒ Object
Name of target (-t, –target).
Class Method Summary collapse
-
.parse(args, banner, params) ⇒ Object
Parsing command-line arguments and returning Options instance.
Instance Attribute Details
#implib_path ⇒ Object
Name of import library path (–implib-path).
70 71 72 |
# File 'lib/mxx_ru/generators/impl/cpp/generation.rb', line 70 def implib_path @implib_path end |
#output_file ⇒ Object
Name of output file (-o, –output-file). nil if missing.
72 73 74 |
# File 'lib/mxx_ru/generators/impl/cpp/generation.rb', line 72 def output_file @output_file end |
#project_path ⇒ Object
Project path (name of project directory in cmd-line).
68 69 70 |
# File 'lib/mxx_ru/generators/impl/cpp/generation.rb', line 68 def project_path @project_path end |
#target_name ⇒ Object
Name of target (-t, –target).
66 67 68 |
# File 'lib/mxx_ru/generators/impl/cpp/generation.rb', line 66 def target_name @target_name end |
Class Method Details
.parse(args, banner, params) ⇒ Object
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.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/mxx_ru/generators/impl/cpp/generation.rb', line 81 def Options.parse( args, , params ) parser = OptionParser.new result = Options.new parser. = 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 |