help_parser 7.0.200907 → 8.0.210917

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7df1feedeed249286efe5cd5f1e2cc187a91d348eab654d5a6f110292d0c3476
4
- data.tar.gz: a3f142a3d2cf4c6bf038b25e3552dfc3f56bfbb3469749386994b0763ccaea4c
3
+ metadata.gz: 89d031ef15e33460fc4f23ccec23cc98f01cb9808fd77bb478c63be6a638f034
4
+ data.tar.gz: 9521262caa0b0a1617fc52bdeec42c4e305a4fc4ce34c5871128c64eecf5aae7
5
5
  SHA512:
6
- metadata.gz: c3df75b2ae4640bc268e86774facbc7f60e74fda4d58c3262022e3a571cb3d716af2be92e7d1652e2ffa5469a1852da4a412e582141f155fe849f37e62d4e4dc
7
- data.tar.gz: 447dfb4939662fec618c4c315f104785e1923a6a625b82ed028981a9ff98c35c9049b23586501c8bd06e244f21de8da4cec2c491bf815a17d3c2d38f93495e4e
6
+ metadata.gz: 4e6c0faa99fd04e8b8e2f289b0f1894538747defaeb557400b36904f7c330961b9cc068aa8bdbe06493f8339af19cd4397cfdca9e1f82bc20ddbf84b91553955
7
+ data.tar.gz: 135b86c92d72faa5b49cdfedd7b6c66a9e568e592ae5b8afc86c612efa23020c828acb45693435d5f5349679f61a963bac81041da6d6bdae9549c1ab2de3214b
data/README.md CHANGED
@@ -1,25 +1,30 @@
1
- # Help Parser VII: Deader
1
+ # Help Parser VIII: Helpland
2
2
 
3
- * [VERSION 7.0.200907](https://github.com/carlosjhr64/Ruby-HelpParser/releases)
4
- * [github](https://www.github.com/carlosjhr64/Ruby-HelpParser)
3
+ * [VERSION 8.0.210917](https://github.com/carlosjhr64/help_parser/releases)
4
+ * [github](https://www.github.com/carlosjhr64/help_parser)
5
5
  * [rubygems](https://rubygems.org/gems/help_parser)
6
6
 
7
7
  ## DESCRIPTION:
8
8
 
9
- Can't help YOU???
10
- You're not the first to say that...
9
+ Welcome to Help Parser!
10
+ Do you have your help text?
11
+ Let's parse!
11
12
 
12
- I will parse your help!
13
+ ## INSTALL:
14
+
15
+ ```console
16
+ $ gem install help_parser
17
+ ```
13
18
 
14
19
  ## SYNOPSIS:
15
20
  <!-- The following PREVIEW has been approved for ALL PROGRAMMERS by CarlosJHR64.
16
21
  For the README validator that checks against me lying....
17
22
  ```ruby
18
- unless File.basename($PROGRAM_NAME) == 'deader'
23
+ unless File.basename($PROGRAM_NAME) == 'party'
19
24
  # For example's sake say
20
- $PROGRAM_NAME = 'deader'
25
+ $PROGRAM_NAME = 'party'
21
26
  # and ARGV is
22
- ARGV.concat ["-\-age", "-\-date=2020-09-07", 'invoke', 'the', 'command']
27
+ ARGV.concat ["-\-age", "-\-date=2020-09-07", 'touch', 'that']
23
28
  # and proceed as if run as:
24
29
  # awesome -\-name=Doe -\-value a b c
25
30
  end
@@ -28,34 +33,35 @@ The following gem has been rated
28
33
  | M | Mature |
29
34
  -->
30
35
 
31
- > Who ever you are, you were meant to find me today...
32
- > there is no turning back!
33
- > Above all, don't invoke the command!
34
-
35
36
  ```ruby
36
37
  require "help_parser"
37
38
 
38
39
  HELP = <<-HELP
39
40
  # <= Hash here, parser skips
40
- # HelpParser: Deader command example #
41
+ # HelpParser: Party command example #
41
42
  Usage:
42
- deader :options+ [<args>+]
43
- deader [:alternate] <arg=FLOAT>
44
- deader literal <arg1=WORD> <arg2=WORD> <arg3=WORD>
43
+ party :options+ [<args>+]
44
+ party [:alternate] <arg=FLOAT>
45
+ party literal <arg1=WORD> <arg2=WORD>
45
46
  Options:
46
47
  -v --version \t Give version and quit
47
48
  -h --help \t Give help and quit
48
49
  -s --long \t Short long synonyms
49
- --command invoke \t Defaulted
50
+ --touch that \t Defaulted
50
51
  --date=DATE \t Typed
51
52
  --age=INTEGER 80 \t Typed and Defaulted
52
53
  -a --all=YN y \t Short, long, typed, and defaulted
53
54
  --to_be
54
55
  --not_to_be
56
+ --rain
57
+ --water
58
+ --wet
55
59
  Exclusive:
56
60
  to_be not_to_be \t Tells parser these are mutually exclusive keys
57
61
  Inclusive:
58
62
  date age \t Tells parser any of these must include all of these
63
+ Conditional:
64
+ rain water wet \t Tells parser if first then all
59
65
  Alternate:
60
66
  --invoke
61
67
  --wut
@@ -67,7 +73,7 @@ Types:
67
73
  YN /^[YNyn]$/
68
74
  # <= Hash here, parser breaks out
69
75
  # Notes #
70
- Don't invoke the command.
76
+ I wouldn't touch that!
71
77
  HELP
72
78
 
73
79
  VERSION = "1.2.3"
@@ -82,30 +88,27 @@ HelpParser.string(:arg1, :arg2, :arg3) # for OPTIONS.arg1, etc : String
82
88
  #=> [:arg1, :arg2, :arg3]
83
89
 
84
90
  ## If run as:
85
- ## deader --age --date=2020-09-07 invoke the command
86
- OPTIONS.age #=> 80
87
- OPTIONS.args #=> ["invoke", "the", "command"]
91
+ ## party --age --date=2020-09-07 touch that
92
+ OPTIONS.age? #=> 80
93
+ OPTIONS.age?.class #=> Integer
94
+ OPTIONS.args? #=> ["touch", "that"]
95
+ OPTIONS.args?.class #=> Array
88
96
  OPTIONS.arg? and OPTIONS.arg #=> false
97
+ OPTIONS.arg?.class #=> FalseClass
89
98
  ```
90
99
 
91
- YOU HAVE INVOKED THE COMMAND...
92
- YOUR HELP BELONGS TO ME!!!
93
-
94
100
  ## Features
95
101
 
96
- * $DEBUG=true on --debug
97
- * $VERBOSE=true on --verbose
102
+ * `$DEBUG=true` on --debug
103
+ * `$VERBOSE=true` on --verbose
98
104
  * -h and --help simultaneously will check help string for errors
99
-
100
- ## INSTALL:
101
-
102
- $ sudo gem install help_parser
105
+ * `HelpParser::REDTTY[msg]` will red color output `msg` to `STDERR`.
103
106
 
104
107
  ## LICENSE:
105
108
 
106
109
  (The MIT License)
107
110
 
108
- Copyright (c) 2020 CarlosJHR64
111
+ Copyright (c) 2021 CarlosJHR64
109
112
 
110
113
  Permission is hereby granted, free of charge, to any person obtaining
111
114
  a copy of this software and associated documentation files (the
@@ -29,8 +29,8 @@ module HelpParser
29
29
  def diagnose
30
30
  dict = {}
31
31
  @specs.each do |k,v|
32
- next if RESERVED[k]
33
- v.flatten.map{|_|_.scan(/\w+/).first}.each{|_|dict[_]=true}
32
+ next if RESERVED.include? k
33
+ v.flatten.map{_1.scan(/\w+/).first}.each{dict[_1]=true}
34
34
  end
35
35
  typos = @hash.keys.select{|k|k.is_a? String and not dict[k]}
36
36
  raise UsageError, MSG[UNRECOGNIZED, typos] unless typos.empty?
@@ -46,10 +46,15 @@ module HelpParser
46
46
  regex = t2r[type]
47
47
  case value
48
48
  when String
49
- raise UsageError, "--#{key}=#{value} !~ #{type}=#{regex.inspect}" unless value=~regex
49
+ unless value=~regex
50
+ raise UsageError, "--#{key}=#{value} !~ #{type}=#{regex.inspect}"
51
+ end
50
52
  when Array
51
53
  value.each do |string|
52
- raise UsageError, "--#{key}=#{string} !~ #{type}=#{regex.inspect}" unless string=~regex
54
+ unless string=~regex
55
+ raise UsageError,
56
+ "--#{key}=#{string} !~ #{type}=#{regex.inspect}"
57
+ end
53
58
  end
54
59
  else
55
60
  raise UsageError, "--#{key} !~ #{type}=#{regex.inspect}"
@@ -106,7 +111,7 @@ module HelpParser
106
111
  end
107
112
  next
108
113
  elsif m=FLAG_GROUP.match(token)
109
- group,plus = m['k'],m['p']
114
+ group,plus = m[:k],m[:p]
110
115
  key = keys[i]
111
116
  raise NoMatch if key.nil? || key.is_a?(Integer)
112
117
  list = @specs[group].flatten.select{|f|f[0]=='-'}.map{|f| F2K[f]}
@@ -121,7 +126,7 @@ module HelpParser
121
126
  elsif m=VARIABLE.match(token)
122
127
  key = keys[i]
123
128
  raise NoMatch unless key.is_a?(Integer)
124
- variable,plus = m['k'],m['p']
129
+ variable,plus = m[:k],m[:p]
125
130
  if plus.nil?
126
131
  @cache[variable] = @hash[key]
127
132
  else
@@ -1,8 +1,19 @@
1
1
  module HelpParser
2
+ V,VSN = 'v','version'
3
+ H,HLP = 'h','help'
4
+ VRBS,DBG = 'verbose','debug'
5
+
6
+ # reserved name
2
7
  USAGE = 'usage'
3
8
  TYPES = 'types'
4
9
  EXCLUSIVE = 'exclusive'
5
10
  INCLUSIVE = 'inclusive'
11
+ CONDITIONAL = 'conditional'
12
+ FLAG_CLUMPS = [EXCLUSIVE,INCLUSIVE,CONDITIONAL]
13
+ RESERVED = [USAGE,TYPES,EXCLUSIVE,INCLUSIVE,CONDITIONAL]
14
+
15
+ # sections
16
+ SECTION_NAME = /^[A-Z]\w+:$/
6
17
 
7
18
  # usage
8
19
  FLAG = /^[-][-]?(?<k>\w+)$/
@@ -16,7 +27,8 @@ module HelpParser
16
27
 
17
28
  # spec -w,? --w+
18
29
  SHORT_LONG = /^[-](?<s>\w),?\s+[-][-](?<k>\w+)$/
19
- SHORT_LONG_DEFAULT = /^[-](?<s>\w),?\s+[-][-](?<k>\w+)(=(?<t>[A-Z]+))?,?\s+(?<d>[^-\s]\S*)$/
30
+ SHORT_LONG_DEFAULT =
31
+ /^[-](?<s>\w),?\s+[-][-](?<k>\w+)(=(?<t>[A-Z]+))?,?\s+(?<d>[^-\s]\S*)$/
20
32
 
21
33
  # spec W+ /~/
22
34
  TYPE_DEF = /^(?<t>[A-Z]+),?\s+\/(?<r>\S+)\/$/
@@ -43,6 +55,7 @@ module HelpParser
43
55
  REDUNDANT = 'Redundant'
44
56
  EXCLUSIVE_KEYS = 'Exclusive keys'
45
57
  INCLUSIVE_KEYS = 'Inclusive keys'
58
+ CONDITIONAL_KEYS = 'Conditional keys'
46
59
  UNBALANCED = 'Unbalanced brackets'
47
60
  UNRECOGNIZED_TOKEN = 'Unrecognized usage token'
48
61
  UNRECOGNIZED_TYPE = 'Unrecognized type spec'
@@ -68,6 +81,7 @@ module HelpParser
68
81
  # lambda utilities
69
82
  MSG = lambda{|msg,*keys| "#{msg}: #{keys.join(' ')}"}
70
83
  F2K = lambda{|f| f[1]=='-' ? f[2..((f.index('=')||0)-1)] : f[1]}
71
- RESERVED = lambda{|k| [USAGE,TYPES,EXCLUSIVE,INCLUSIVE].include?(k)} # reserved
72
- REDTTY = lambda{|msg,out=$stderr| out.tty? ? out.puts("\033[0;31m#{msg}\033[0m"): out.puts(msg)}
84
+ REDTTY = lambda{|msg,out=$stderr|
85
+ out.tty? ? out.puts("\033[0;31m#{msg}\033[0m"): out.puts(msg)
86
+ }
73
87
  end
@@ -1,10 +1,11 @@
1
1
  module HelpParser
2
2
  def self.k2t(specs)
3
3
  k2t = NoDupHash.new
4
- tokens = specs.select{|k,v| !(k==TYPES)}.values.flatten.select{|v|v.include?('=')}
4
+ tokens = specs.select{|k,v| !(k==TYPES)}.values.flatten
5
+ .select{|v|v.include?('=')}
5
6
  tokens.each do |token|
6
7
  if match = VARIABLE.match(token) || LONG.match(token)
7
- name, type = match['k'], match['t']
8
+ name, type = match[:k], match[:t]
8
9
  if _=k2t[name]
9
10
  raise HelpError, MSG[INCONSISTENT,name,type,_] unless type==_
10
11
  else
@@ -20,7 +20,8 @@ module HelpParser
20
20
  class Options
21
21
  def #{name}?
22
22
  s = @hash['#{name}']
23
- raise UsageError, MSG[NOT_STRING,'#{name}'] unless s.nil? || s.is_a?(String)
23
+ raise UsageError, MSG[NOT_STRING,'#{name}'] unless s.nil? ||
24
+ s.is_a?(String)
24
25
  return s
25
26
  end
26
27
  end
@@ -50,7 +51,8 @@ module HelpParser
50
51
  class Options
51
52
  def #{name}?
52
53
  a = @hash['#{name}']
53
- raise UsageError, MSG[NOT_STRINGS,'#{name}'] unless a.nil? || a.is_a?(Array)
54
+ raise UsageError, MSG[NOT_STRINGS,'#{name}'] unless a.nil? ||
55
+ a.is_a?(Array)
54
56
  return a
55
57
  end
56
58
  end
@@ -100,7 +102,7 @@ module HelpParser
100
102
  def #{name}
101
103
  f = @hash['#{name}']
102
104
  raise unless f.is_a?(Array)
103
- f.map{|_|_.to_f}
105
+ f.map{_1.to_f}
104
106
  rescue
105
107
  raise UsageError, MSG[#{NOT_FLOATS},'#{name}']
106
108
  end
@@ -118,7 +120,7 @@ module HelpParser
118
120
  f = @hash['#{name}']
119
121
  return nil unless f
120
122
  raise unless f.is_a?(Array)
121
- f.map{|_|_.to_f}
123
+ f.map{_1.to_f}
122
124
  rescue
123
125
  raise UsageError, MSG[NOT_FLOATS,'#{name}']
124
126
  end
@@ -169,7 +171,7 @@ module HelpParser
169
171
  def #{name}
170
172
  f = @hash['#{name}']
171
173
  raise unless f.is_a?(Array)
172
- f.map{|_|_.to_i}
174
+ f.map{_1.to_i}
173
175
  rescue
174
176
  raise UsageError, MSG[NOT_INTEGERS,'#{name}']
175
177
  end
@@ -187,7 +189,7 @@ module HelpParser
187
189
  f = @hash['#{name}']
188
190
  return nil unless f
189
191
  raise unless f.is_a?(Array)
190
- f.map{|_|_.to_i}
192
+ f.map{_1.to_i}
191
193
  rescue
192
194
  raise UsageError, MSG[NOT_INTEGERS,'#{name}']
193
195
  end
@@ -2,36 +2,45 @@ module HelpParser
2
2
  class Options
3
3
  def initialize(version, help, argv)
4
4
  @hash = HelpParser.parsea(argv)
5
- if version && (@hash.has_key?('v') || @hash.has_key?('version'))
5
+ if version && (@hash.has_key?(V) || @hash.has_key?(VSN))
6
6
  # -v or --version
7
7
  raise VersionException, version
8
8
  end
9
9
  if help
10
- h = ['h', 'help']
11
- if h.any?{|_|@hash.key?_}
12
- HelpParser.parseh(help, validate: true) if h.all?{|_|@hash.key?_}
10
+ h = [H, HLP]
11
+ if h.any?{@hash.key? _1}
12
+ HelpParser.parseh(help, validate: true) if h.all?{@hash.key? _1}
13
13
  raise HelpException, help
14
14
  end
15
15
  specs = HelpParser.parseh(help)
16
16
  Completion.new(@hash, specs)
17
17
  if exclusive=specs[EXCLUSIVE]
18
18
  exclusive.each do |x|
19
- count = @hash.keys.count{|k|x.include?(k)}
19
+ count = x.count{@hash.key? _1}
20
20
  raise HelpParser::UsageError, MSG[EXCLUSIVE_KEYS,*x] if count > 1
21
21
  end
22
22
  end
23
23
  if inclusive=specs[INCLUSIVE]
24
24
  inclusive.each do |i|
25
- count = @hash.keys.count{|k|i.include?(k)}
26
- raise HelpParser::UsageError, MSG[INCLUSIVE_KEYS,*i] unless count==0 or count==i.length
25
+ count = i.count{@hash.key? _1}
26
+ unless count==0 or count==i.length
27
+ raise HelpParser::UsageError, MSG[INCLUSIVE_KEYS,*i]
28
+ end
29
+ end
30
+ end
31
+ if conditional=specs[CONDITIONAL]
32
+ conditional.each do |c|
33
+ if @hash.key? c[0] and not c.all?{@hash.key? _1}
34
+ raise HelpParser::UsageError, MSG[CONDITIONAL_KEYS,*c]
35
+ end
27
36
  end
28
37
  end
29
38
  end
30
- $VERBOSE = true if @hash['verbose']==true
31
- $DEBUG = true if @hash['debug']==true
39
+ $VERBOSE = true if @hash[VRBS]==true
40
+ $DEBUG = true if @hash[DBG]==true
32
41
  end
33
42
 
34
- def _hash
43
+ def to_h
35
44
  @hash
36
45
  end
37
46
 
@@ -4,7 +4,7 @@ module HelpParser
4
4
  help.each_line do |line|
5
5
  line.chomp!
6
6
  next if line==''
7
- if line=~/^[A-Z]\w+:$/
7
+ if line=~SECTION_NAME
8
8
  name = line[0..-2].downcase
9
9
  specs[name] = []
10
10
  else
@@ -15,29 +15,32 @@ module HelpParser
15
15
  raise HelpError, EXTRANEOUS_SPACES if validate and spec==''
16
16
  case name
17
17
  when USAGE
18
- HelpParser.validate_line_chars(spec.chars) if validate
18
+ Validate.line_chars(spec.chars) if validate
19
19
  tokens = HelpParser.parseu(spec.chars)
20
- HelpParser.validate_usage_tokens(tokens) if validate
20
+ Validate.usage_tokens(tokens) if validate
21
21
  specs[USAGE].push tokens
22
22
  when TYPES
23
- raise HelpError, MSG[UNRECOGNIZED_TYPE,spec] if validate and not spec=~TYPE_DEF
23
+ if validate and not spec=~TYPE_DEF
24
+ raise HelpError, MSG[UNRECOGNIZED_TYPE,spec]
25
+ end
24
26
  specs[TYPES].push spec.split(CSV)
25
- when EXCLUSIVE,INCLUSIVE
26
- raise HelpError, MSG[UNRECOGNIZED_X,spec] if validate and not spec=~X_DEF
27
+ when *FLAG_CLUMPS # EXCLUSIVE,INCLUSIVE,CONDITIONAL,...
28
+ if validate and not spec=~X_DEF
29
+ raise HelpError, MSG[UNRECOGNIZED_X,spec]
30
+ end
27
31
  specs[name].push spec.split(CSV)
28
32
  else
29
- if validate and not [SHORT, LONG, SHORT_LONG, SHORT_LONG_DEFAULT].any?{|_|_=~spec}
30
- raise HelpError, MSG[UNRECOGNIZED_OPTION,spec]
31
- end
33
+ raise HelpError, MSG[UNRECOGNIZED_OPTION,spec] if validate and
34
+ not [SHORT, LONG, SHORT_LONG, SHORT_LONG_DEFAULT].any?{_1=~spec}
32
35
  specs[name].push spec.split(CSV)
33
36
  end
34
37
  end
35
38
  end
36
39
  if validate
37
- HelpParser.validate_usage_specs(specs)
40
+ Validate.usage_specs(specs)
38
41
  if t2r = HelpParser.t2r(specs)
39
42
  k2t = HelpParser.k2t(specs)
40
- HelpParser.validate_k2t2r(specs, k2t, t2r)
43
+ Validate.k2t2r(specs, k2t, t2r)
41
44
  end
42
45
  end
43
46
  return specs
@@ -1,5 +1,6 @@
1
1
  module HelpParser
2
- def self.validate_line_chars(chars)
2
+ module Validate
3
+ def self.line_chars(chars)
3
4
  count = 0
4
5
  chars.each do |c|
5
6
  if c=='['
@@ -12,7 +13,7 @@ module HelpParser
12
13
  raise HelpError, MSG[UNBALANCED,chars.join] unless count==0
13
14
  end
14
15
 
15
- def self.validate_usage_tokens(tokens)
16
+ def self.usage_tokens(tokens)
16
17
  words = []
17
18
  tokens.flatten.each do |token|
18
19
  match = token.match(FLAG) ||
@@ -20,22 +21,24 @@ module HelpParser
20
21
  token.match(VARIABLE) ||
21
22
  token.match(FLAG_GROUP)
22
23
  raise HelpError, MSG[UNRECOGNIZED_TOKEN,token] unless match
23
- words.push match['k'] # key
24
+ words.push match[:k] # key
24
25
  end
25
26
  words.each_with_index do |word,i|
26
27
  raise HelpError, MSG[DUP_WORD,word] unless i==words.rindex(word)
27
28
  end
28
29
  end
29
30
 
30
- def self.validate_usage_specs(specs)
31
- option_specs = specs.select{|a,b| !RESERVED[a]}
31
+ def self.usage_specs(specs)
32
+ option_specs = specs.select{|a,b| not RESERVED.include? a}
32
33
  flags = option_specs.values.flatten.select{|f|f[0]=='-'}.map{|f| F2K[f]}
33
- [EXCLUSIVE,INCLUSIVE].each do |k|
34
+ FLAG_CLUMPS.each do |k|
34
35
  if a=specs[k]
35
36
  seen = {}
36
37
  a.each do |xs|
37
38
  k = xs.sort.join(' ').to_sym
38
- raise HelpError, MSG[DUP_X,k] if seen[k] or not xs.length==xs.uniq.length
39
+ if seen[k] or not xs.length==xs.uniq.length
40
+ raise HelpError, MSG[DUP_X,k]
41
+ end
39
42
  seen[k] = true
40
43
  xs.each do |x|
41
44
  raise HelpError, MSG[UNSEEN_FLAG, x] unless flags.include?(x)
@@ -51,7 +54,7 @@ module HelpParser
51
54
  unless specs_usage.nil?
52
55
  specs_usage.flatten.each do |token|
53
56
  if match = token.match(FLAG_GROUP)
54
- key = match['k']
57
+ key = match[:k]
55
58
  raise HelpError, MSG[UNDEFINED_SECTION,key] unless specs[key]
56
59
  group.push(key)
57
60
  end
@@ -59,12 +62,12 @@ module HelpParser
59
62
  end
60
63
  specs.each do |key,tokens|
61
64
  raise HelpError, MSG[MISSING_CASES,key] unless tokens.size>0
62
- next if specs_usage.nil? or RESERVED[key]
65
+ next if specs_usage.nil? or RESERVED.include? key
63
66
  raise HelpError, MSG[MISSING_USAGE,key] unless group.include?(key)
64
67
  end
65
68
  end
66
69
 
67
- def self.validate_k2t2r(specs, k2t, t2r)
70
+ def self.k2t2r(specs, k2t, t2r)
68
71
  a,b = k2t.values.uniq.sort,t2r.keys.sort
69
72
  unless a==b
70
73
  c = (a+b).uniq.select{|x|!(a.include?(x) && b.include?(x))}
@@ -82,8 +85,11 @@ module HelpParser
82
85
  long = long_type[2..(i-1)]
83
86
  type = long_type[(i+1)..-1]
84
87
  regex = t2r[type]
85
- raise HelpError, MSG[BAD_DEFAULT,long,default,type,regex.inspect] unless regex=~default
88
+ unless regex=~default
89
+ raise HelpError, MSG[BAD_DEFAULT,long,default,type,regex.inspect]
90
+ end
86
91
  end
87
92
  end
88
93
  end
89
94
  end
95
+ end
data/lib/help_parser.rb CHANGED
@@ -1,17 +1,17 @@
1
- require_relative './help_parser/constants'
2
- require_relative './help_parser/exceptions'
3
- require_relative './help_parser/aliases'
4
- require_relative './help_parser/parsea'
5
- require_relative './help_parser/validations'
6
- require_relative './help_parser/parseu'
7
- require_relative './help_parser/parseh'
8
- require_relative './help_parser/k2t2r'
9
- require_relative './help_parser/completion'
10
- require_relative './help_parser/options'
11
- require_relative './help_parser/macros'
1
+ require_relative 'help_parser/constants'
2
+ require_relative 'help_parser/exceptions'
3
+ require_relative 'help_parser/aliases'
4
+ require_relative 'help_parser/parsea'
5
+ require_relative 'help_parser/parseu'
6
+ require_relative 'help_parser/parseh'
7
+ require_relative 'help_parser/k2t2r'
8
+ require_relative 'help_parser/completion'
9
+ require_relative 'help_parser/options'
10
+ require_relative 'help_parser/macros'
12
11
 
13
12
  module HelpParser
14
- VERSION = '7.0.200907'
13
+ VERSION = '8.0.210917'
14
+ autoload :Validate, 'help_parser/validate'
15
15
 
16
16
  def self.[](
17
17
  version = nil,
@@ -21,16 +21,6 @@ module HelpParser
21
21
  rescue HelpParserException => exception
22
22
  exception.exit
23
23
  end
24
-
25
- def self.run(
26
- version = nil,
27
- help = nil,
28
- argv = [File.basename($0)]+ARGV)
29
- options = Options.new(version, help, argv)
30
- yield options
31
- rescue HelpParserException => exception
32
- exception.exit
33
- end
34
24
  end
35
25
 
36
26
  # Requires:
metadata CHANGED
@@ -1,20 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: help_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.200907
4
+ version: 8.0.210917
5
5
  platform: ruby
6
6
  authors:
7
- - carlosjhr64
8
- autorequire:
7
+ - CarlosJHR64
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-07 00:00:00.000000000 Z
11
+ date: 2021-09-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: |
14
- Can't help YOU???
15
- You're not the first to say that...
16
-
17
- I will parse your help!
13
+ description: "Welcome to Help Parser! \nDo you have your help text? \nLet's parse!\n"
18
14
  email: carlosjhr64@gmail.com
19
15
  executables: []
20
16
  extensions: []
@@ -33,12 +29,12 @@ files:
33
29
  - lib/help_parser/parsea.rb
34
30
  - lib/help_parser/parseh.rb
35
31
  - lib/help_parser/parseu.rb
36
- - lib/help_parser/validations.rb
37
- homepage: https://github.com/carlosjhr64/Ruby-HelpParser
32
+ - lib/help_parser/validate.rb
33
+ homepage: https://github.com/carlosjhr64/help_parser
38
34
  licenses:
39
35
  - MIT
40
36
  metadata: {}
41
- post_install_message:
37
+ post_install_message:
42
38
  rdoc_options: []
43
39
  require_paths:
44
40
  - lib
@@ -53,9 +49,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
49
  - !ruby/object:Gem::Version
54
50
  version: '0'
55
51
  requirements:
56
- - 'ruby: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]'
57
- rubygems_version: 3.1.2
58
- signing_key:
52
+ - 'ruby: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]'
53
+ rubygems_version: 3.2.22
54
+ signing_key:
59
55
  specification_version: 4
60
- summary: Can't help YOU??? You're not the first to say that...
56
+ summary: Welcome to Help Parser! Do you have your help text? Let's parse!
61
57
  test_files: []