Class: Bhook::ArgsParser
- Inherits:
-
Object
- Object
- Bhook::ArgsParser
- Extended by:
- T::Sig
- Defined in:
- lib/bhook/args_parser.rb
Defined Under Namespace
Classes: Options
Instance Method Summary collapse
- #help_text ⇒ Object
-
#initialize(argv) ⇒ ArgsParser
constructor
A new instance of ArgsParser.
- #parse ⇒ Object
Constructor Details
#initialize(argv) ⇒ ArgsParser
Returns a new instance of ArgsParser.
10 11 12 13 14 |
# File 'lib/bhook/args_parser.rb', line 10 def initialize(argv) @args = Options.new(nil, nil, false, false, Bhook::THEME_DIR_PATH, nil, false, nil, false) @argv = argv.clone @opt_parser = build_opt_parser end |
Instance Method Details
#help_text ⇒ Object
34 35 36 |
# File 'lib/bhook/args_parser.rb', line 34 def help_text @opt_parser.to_s end |
#parse ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bhook/args_parser.rb', line 16 def parse if (mount = detect_and_read_mount_args_from_config_in_pwd) @args.mount = mount end begin @opt_parser.parse(@argv) if generate_theme_missing? && help_missing? && source_or_output_paths_missing? && mount_config_missing? raise OptionParser::MissingArgument, 'See --help.' end rescue OptionParser::ParseError => e puts "\nError! #{e.}\n" return nil end @args end |