Class: Parser
- Inherits:
-
Object
- Object
- Parser
- Defined in:
- lib/check_xcode_xmls/arguments_parser.rb
Overview
Parses command line arguments
Class Method Summary collapse
Class Method Details
.parse(argv) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/check_xcode_xmls/arguments_parser.rb', line 28 def self.parse(argv) # If no arguments supplied, print help argv << '-h' if argv.empty? result = = OptionParser.new do |o| o. = 'Usage: {SCRIPT_NAME} [input directory]' # nandrei add an ignore option. o.on('-h', '--help', 'Prints this help') do puts exit 0 end o.on('-iIGNORE', '--ignore-regex=IGNORE', 'Case sensitive ignore files regex. Eg. "Ignore|Debug"') do |v| result.ignore_regex_string = v end o.on('-e', '--echo', 'Echo invocation') do |_v| result.echo_invocation = true end o.on('-t', '--total', 'Print total') do |_v| result.print_totals = true end o.on('--check-constraints-identifiers', 'Check files for constraints that don\'t have identifiers') do |_v| result.check_constraints_identifiers = true end o.on('--check-use-autolayout', 'Find files which don\'t use autolayout') do |_v| result.check_use_autolayout = true end end begin .parse!(argv) rescue StandardError => exception puts exception puts exit 1 end result.input_directory = argv.pop if result.input_directory.nil? || !Dir.exist?(result.input_directory) directory = result.input_directory || '' puts 'Can\'t find directory ' + directory Parser.parse %w[--help] exit 0 end result end |