Class: CovLoupe::ConfigParser
- Inherits:
-
Object
- Object
- CovLoupe::ConfigParser
- Defined in:
- lib/cov_loupe/config/config_parser.rb
Overview
Parses command-line arguments into an AppConfig.
Used in both CLI and MCP modes to extract mode, log file, and other global settings before dispatching to the appropriate runner. Uses order! so that subcommand-specific options (e.g., 'validate -i') are not consumed by the global parser.
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
-
.parse(argv) ⇒ AppConfig
Parse argv (with env opts already merged) and return config.
Instance Method Summary collapse
-
#initialize(argv) ⇒ ConfigParser
constructor
A new instance of ConfigParser.
- #parse ⇒ Object
Constructor Details
#initialize(argv) ⇒ ConfigParser
Returns a new instance of ConfigParser.
16 17 18 19 |
# File 'lib/cov_loupe/config/config_parser.rb', line 16 def initialize(argv) @argv = argv @config = AppConfig.new end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
14 15 16 |
# File 'lib/cov_loupe/config/config_parser.rb', line 14 def argv @argv end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
14 15 16 |
# File 'lib/cov_loupe/config/config_parser.rb', line 14 def config @config end |
Class Method Details
.parse(argv) ⇒ AppConfig
Parse argv (with env opts already merged) and return config
24 25 26 |
# File 'lib/cov_loupe/config/config_parser.rb', line 24 def self.parse(argv) new(argv).parse end |
Instance Method Details
#parse ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cov_loupe/config/config_parser.rb', line 28 def parse # Build and execute the option parser parser = OptionParserBuilder.new(config).build_option_parser # Use order! to stop at the first non-option argument (the subcommand). # This ensures that subcommand-specific options (like 'validate -i') are not # stripped by the global option parser. parser.order!(argv) config.validate! end |