libclimate-ruby 0.11.0 → 0.12.0

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
  SHA1:
3
- metadata.gz: 353fcd858d3ab427e53c1a9413dd95b84a51ce60
4
- data.tar.gz: 4e6800354074160420024c735c9c74c25479b61e
3
+ metadata.gz: 60fb29259bdb557a306c02a204cf7b801695aea7
4
+ data.tar.gz: 599e221a43e094f0a88ddea9d99a4a87812c78db
5
5
  SHA512:
6
- metadata.gz: 66435e1e61927c1c2cb3f8deeff70622ef6fe11d7829597fcdebf3e4310fde56c3d80d084cf29261f82f8914d344d97168e51a1de274f1c1a44560e44e411a10
7
- data.tar.gz: 56b07a2b44395c8e0c72e7c6c553285a2f4de427a1cfc2268c49b7e8ac33ab9978de755f9c188eb0e4504f19d054b00db3ffd0c5b54c3fda40e33a99b958ce64
6
+ metadata.gz: b537e1f71fb463e8f60197e0e3174607fdcaa49afcd9f4beb1cd7c86f04ff6b72e61cea87e27725bc3dce9803906872345a293aea2ac704348195dfcc4b2b6b6
7
+ data.tar.gz: a62dbfe4a7bc2fef06ab0dee37c6351c04118170432e2109a828d3515ada0e19910b88e8f2d9b93d38e18867685b34e8e8e80f3cdb901ade0f9089456e325ad7
data/README.md CHANGED
@@ -17,7 +17,8 @@ libCLImate, for Ruby
17
17
  1. [Introduction](#introduction)
18
18
  2. [Installation](#installation)
19
19
  3. [Components](#components)
20
- 4. [Project Information](#project-information)
20
+ 4. [Examples](#examples)
21
+ 5. [Project Information](#project-information)
21
22
 
22
23
  ## Installation
23
24
 
@@ -29,16 +30,22 @@ Install via **gem** as in:
29
30
 
30
31
  or add it to your `Gemfile`.
31
32
 
32
- Use via **require***, as in:
33
+ Use via **require**, as in:
33
34
 
34
35
  ```Ruby
35
- require 'libclimate-ruby'
36
+ require 'libclimate'
36
37
  ```
37
38
 
38
39
  ## Components
39
40
 
40
41
  T.B.C.
41
42
 
43
+ ## Examples
44
+
45
+ Examples are provided in the ```examples``` directory, along with a markdown description for each. A detailed list TOC of them is provided in [EXAMPLES.md](./EXAMPLES.md).
46
+
47
+ It is instructive to see how much more succinct they are than those (offering precisely the same functionality) presented in [**CLASP.Ruby**](https://github.com/synesissoftware/CLASP.Ruby).
48
+
42
49
  ## Project Information
43
50
 
44
51
  ### Where to get help
@@ -58,12 +65,12 @@ Defect reports, feature requests, and pull requests are welcome on https://githu
58
65
 
59
66
  ### Related projects
60
67
 
61
- * [**libCLImate C/C++](https://github.com/synesissoftware/libCLImate.Ruby)
62
68
  * [**CLASP**](https://github.com/synesissoftware/CLASP/)
63
69
  * [**CLASP.Go**](https://github.com/synesissoftware/CLASP.Go/)
64
70
  * [**CLASP.js**](https://github.com/synesissoftware/CLASP.js/)
65
71
  * [**CLASP.Ruby**](https://github.com/synesissoftware/CLASP.Ruby/)
66
- * [xqsr3](https://github.com/synesissoftware.com/libCLImate.Ruby-xml/)
72
+ * [**libCLImate** (C/C++)](https://github.com/synesissoftware/libCLImate.Ruby)
73
+ * [**xqsr3**](https://github.com/synesissoftware.com/libCLImate.Ruby-xml/)
67
74
 
68
75
  ### License
69
76
 
@@ -0,0 +1,181 @@
1
+ # libCLImate.Ruby Example - **show_usage_and_version**
2
+
3
+ ## Summary
4
+
5
+ Example illustrating various kinds of *flag* and *option* specifications, including the combination of short-names.
6
+
7
+ ## Source
8
+
9
+ ```ruby
10
+ #!/usr/bin/env ruby
11
+
12
+ # examples/flag_and_option_specifications.rb
13
+
14
+ # requires
15
+
16
+ require 'libclimate'
17
+
18
+ # Specify specifications, parse, and checking standard flags
19
+
20
+ options = {}
21
+ climate = LibCLImate::Climate.new do |cl|
22
+
23
+ cl.add_flag('--debug', alias: '-d', help: 'runs in Debug mode') do
24
+
25
+ options[:debug] = true
26
+ end
27
+ cl.add_option('--verbosity', alias: '-v', help: 'specifies the verbosity', values: [ 'terse', 'quiet', 'silent', 'chatty' ]) do |o, a|
28
+
29
+ options[:verbosity] = o.value
30
+ end
31
+ cl.add_alias('--verbosity=chatty', '-c')
32
+
33
+ cl.version = [ 0, 0, 1 ]
34
+
35
+ cl.info_lines = [
36
+
37
+ 'libCLImate.Ruby examples',
38
+ :version,
39
+ "Illustrates use of libCLImate.Ruby's specification of flags, options, and specifications",
40
+ '',
41
+ ]
42
+ end
43
+
44
+ r = climate.run ARGV
45
+
46
+
47
+
48
+ # Program-specific processing of flags/options
49
+
50
+ if options[:verbosity]
51
+
52
+ $stdout.puts "verbosity is specified as: #{options[:verbosity]}"
53
+ end
54
+
55
+ if options[:debug]
56
+
57
+ $stdout.puts 'Debug mode is specified'
58
+ end
59
+ ```
60
+
61
+ ## Usage
62
+
63
+ ### No arguments
64
+
65
+ If executed with no arguments
66
+
67
+ ```
68
+ ruby examples/flag_and_option_specifications.rb
69
+ ```
70
+
71
+ or (in a Unix shell):
72
+
73
+ ```
74
+ ./examples/flag_and_option_specifications.rb
75
+ ```
76
+
77
+ it gives the output:
78
+
79
+ ```
80
+ ```
81
+
82
+ ### Show usage
83
+
84
+ If executed with the arguments
85
+
86
+ ```
87
+ ruby examples/flag_and_option_specifications.rb --help
88
+ ```
89
+
90
+ it gives the output:
91
+
92
+ ```
93
+ libCLImate.Ruby examples
94
+ flag_and_option_specifications.rb 0.0.1
95
+ Illustrates use of libCLImate.Ruby's specification of flags, options, and specifications
96
+
97
+ USAGE: flag_and_option_specifications.rb [ ... flags and options ... ]
98
+
99
+ flags/options:
100
+
101
+ -d
102
+ --debug
103
+ runs in Debug mode
104
+
105
+ -c --verbosity=chatty
106
+ -v <value>
107
+ --verbosity=<value>
108
+ specifies the verbosity
109
+ where <value> one of:
110
+ terse
111
+ quiet
112
+ silent
113
+ chatty
114
+
115
+ --help
116
+ Shows usage and terminates
117
+
118
+ --version
119
+ Shows version and terminates
120
+ ```
121
+
122
+ ### Specify flags and options in long-form
123
+
124
+ If executed with the arguments
125
+
126
+ ```
127
+ ruby examples/flag_and_option_specifications.rb --debug --verbosity=silent
128
+ ```
129
+
130
+ it gives the output:
131
+
132
+ ```
133
+ verbosity is specified as: silent
134
+ Debug mode is specified
135
+ ```
136
+
137
+ ### Specify flags and options in short-form
138
+
139
+ If executed with the arguments
140
+
141
+ ```
142
+ ruby examples/flag_and_option_specifications.rb -v silent -d
143
+ ```
144
+
145
+ it gives the (same) output:
146
+
147
+ ```
148
+ verbosity is specified as: silent
149
+ Debug mode is specified
150
+ ```
151
+
152
+ ### Specify flags and options in short-form, including an alias for an option-with-value
153
+
154
+ If executed with the arguments
155
+
156
+ ```
157
+ ruby examples/flag_and_option_specifications.rb -c -d
158
+ ```
159
+
160
+ it gives the output:
161
+
162
+ ```
163
+ verbosity is specified as: chatty
164
+ Debug mode is specified
165
+ ```
166
+
167
+ ### Specify flags and options with combined short-form
168
+
169
+ If executed with the arguments
170
+
171
+ ```
172
+ ruby examples/flag_and_option_specifications.rb -dc
173
+ ```
174
+
175
+ it gives the (same) output:
176
+
177
+ ```
178
+ verbosity is specified as: chatty
179
+ Debug mode is specified
180
+ ```
181
+
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # examples/flag_and_option_specifications.rb
4
+
5
+ # requires
6
+
7
+ require 'libclimate'
8
+
9
+ # Specify specifications, parse, and checking standard flags
10
+
11
+ options = {}
12
+ climate = LibCLImate::Climate.new do |cl|
13
+
14
+ cl.add_flag('--debug', alias: '-d', help: 'runs in Debug mode') do
15
+
16
+ options[:debug] = true
17
+ end
18
+ cl.add_option('--verbosity', alias: '-v', help: 'specifies the verbosity', values: [ 'terse', 'quiet', 'silent', 'chatty' ]) do |o, a|
19
+
20
+ options[:verbosity] = o.value
21
+ end
22
+ cl.add_alias('--verbosity=chatty', '-c')
23
+
24
+ cl.version = [ 0, 0, 1 ]
25
+
26
+ cl.info_lines = [
27
+
28
+ 'libCLImate.Ruby examples',
29
+ :version,
30
+ "Illustrates use of libCLImate.Ruby's specification of flags, options, and specifications",
31
+ '',
32
+ ]
33
+ end
34
+
35
+ r = climate.run ARGV
36
+
37
+
38
+
39
+ # Program-specific processing of flags/options
40
+
41
+ if options[:verbosity]
42
+
43
+ $stdout.puts "verbosity is specified as: #{options[:verbosity]}"
44
+ end
45
+
46
+ if options[:debug]
47
+
48
+ $stdout.puts 'Debug mode is specified'
49
+ end
50
+
51
+
52
+
53
+
@@ -0,0 +1,117 @@
1
+ # libCLImate.Ruby Example - **show_usage_and_version**
2
+
3
+ ## Summary
4
+
5
+ Simple example supporting ```--help``` and ```--version```.
6
+
7
+ ## Source
8
+
9
+ ```ruby
10
+ #!/usr/bin/env ruby
11
+
12
+ # examples/show_usage_and_version.rb
13
+
14
+ # requires
15
+
16
+ require 'libclimate'
17
+
18
+ # Specify specifications, parse, and checking standard flags
19
+
20
+ climate = LibCLImate::Climate.new do |cl|
21
+
22
+ cl.version = [ 0, 0, 1 ]
23
+
24
+ cl.info_lines = [
25
+
26
+ 'libCLImate.Ruby examples',
27
+ :version,
28
+ "Illustrates use of libCLImate.Ruby's automatic support for '--help' and '--version'",
29
+ '',
30
+ ]
31
+ end
32
+
33
+ climate.run ARGV
34
+
35
+
36
+
37
+ $stdout.puts 'no flags specified'
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ ### No arguments
43
+
44
+ If executed with no arguments
45
+
46
+ ```
47
+ ruby examples/show_usage_and_version.rb
48
+ ```
49
+
50
+ or (in a Unix shell):
51
+
52
+ ```
53
+ ./examples/show_usage_and_version.rb
54
+ ```
55
+
56
+ it gives the output:
57
+
58
+ ```
59
+ no flags specified
60
+ ```
61
+
62
+ ### Show usage
63
+
64
+ If executed with the arguments
65
+
66
+ ```
67
+ ruby examples/show_usage_and_version.rb --help
68
+ ```
69
+
70
+ it gives the output:
71
+
72
+ ```
73
+ libCLImate.Ruby examples
74
+ show_usage_and_version.rb 0.0.1
75
+ Illustrates use of libCLImate.Ruby's automatic support for '--help' and '--version'
76
+
77
+ USAGE: show_usage_and_version.rb [ ... flags and options ... ]
78
+
79
+ flags/options:
80
+
81
+ --help
82
+ shows this help and terminates
83
+
84
+ --version
85
+ shows version and terminates
86
+ ```
87
+
88
+ ### Show version
89
+
90
+ If executed with the arguments
91
+
92
+ ```
93
+ ruby examples/show_usage_and_version.rb --version
94
+ ```
95
+
96
+ it gives the output:
97
+
98
+ ```
99
+ show_usage_and_version.rb 0.0.1
100
+ ```
101
+
102
+ ### Unknown option
103
+
104
+ If executed with the arguments
105
+
106
+ ```
107
+ ruby examples/show_usage_and_version.rb --unknown=value
108
+ ```
109
+
110
+ it gives the output (on the standard error stream):
111
+
112
+ ```
113
+ show_usage_and_version.rb: unrecognised flag/option: --unknown=value
114
+ ```
115
+
116
+ with an exit code of 1
117
+
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # examples/show_usage_and_version.rb
4
+
5
+ # requires
6
+
7
+ require 'libclimate'
8
+
9
+ # Specify specifications, parse, and checking standard flags
10
+
11
+ climate = LibCLImate::Climate.new do |cl|
12
+
13
+ cl.version = [ 0, 0, 1 ]
14
+
15
+ cl.info_lines = [
16
+
17
+ 'libCLImate.Ruby examples',
18
+ :version,
19
+ "Illustrates use of libCLImate.Ruby's automatic support for '--help' and '--version'",
20
+ '',
21
+ ]
22
+ end
23
+
24
+ climate.run ARGV
25
+
26
+
27
+
28
+ $stdout.puts 'no flags specified'
29
+
30
+
@@ -5,7 +5,7 @@
5
5
  # Purpose: Definition of the ::LibCLImate::Climate class
6
6
  #
7
7
  # Created: 13th July 2015
8
- # Updated: 12th March 2019
8
+ # Updated: 10th April 2019
9
9
  #
10
10
  # Home: http://github.com/synesissoftware/libCLImate.Ruby
11
11
  #
@@ -171,12 +171,12 @@ class Climate
171
171
  options[:values] = usage_values if usage_values
172
172
  options[:flags_and_options] = flags_and_options if flags_and_options
173
173
 
174
- CLASP.show_usage aliases, options
174
+ CLASP.show_usage specifications, options
175
175
  end
176
176
 
177
177
  def show_version_
178
178
 
179
- CLASP.show_version aliases, stream: stdout, program_name: program_name, version: version, exit: exit_on_usage ? 0 : nil
179
+ CLASP.show_version specifications, stream: stdout, program_name: program_name, version: version, exit: exit_on_usage ? 0 : nil
180
180
  end
181
181
 
182
182
  def infer_version_ ctxt
@@ -272,9 +272,9 @@ class Climate
272
272
  #
273
273
  # * *Options*:
274
274
  # - +:no_help_flag+:: (boolean) Prevents the use of the
275
- # +CLASP::Flag.Help+ flag-alias
275
+ # +CLASP::Flag.Help+ flag-specification
276
276
  # - +:no_version_flag+:: (boolean) Prevents the use of the
277
- # +CLASP::Flag.Version+ flag-alias
277
+ # +CLASP::Flag.Version+ flag-specification
278
278
  # - +:program_name+:: (::String) An explicit program-name, which is
279
279
  # inferred from +$0+ if this is +nil+
280
280
  # - +:version+:: A version specification. If not specified, this is
@@ -301,7 +301,7 @@ class Climate
301
301
  pr_name = (pr_name =~ /\.(?:bat|cmd|rb|sh)$/) ? "#$`(#$&)" : pr_name
302
302
  end
303
303
 
304
- @aliases = []
304
+ @specifications = []
305
305
  @ignore_unknown = false
306
306
  @exit_on_unknown = true
307
307
  @exit_on_missing = true
@@ -317,8 +317,8 @@ class Climate
317
317
  version_context = options[:version_context]
318
318
  @version = options[:version] || infer_version_(version_context)
319
319
 
320
- @aliases << CLASP::Flag.Help(handle: proc { show_usage_ }) unless options[:no_help_flag]
321
- @aliases << CLASP::Flag.Version(handle: proc { show_version_ }) unless options[:no_version_flag]
320
+ @specifications << CLASP::Flag.Help(handle: proc { show_usage_ }) unless options[:no_help_flag]
321
+ @specifications << CLASP::Flag.Version(handle: proc { show_version_ }) unless options[:no_version_flag]
322
322
 
323
323
  yield self if block_given?
324
324
  end
@@ -332,9 +332,11 @@ class Climate
332
332
  @program_name = name
333
333
  end
334
334
 
335
- # An array of aliases attached to the climate instance, whose contents should be modified by adding (or removing) CLASP aliases
336
- # @return (::Array) The aliases
337
- attr_reader :aliases
335
+ # An array of specifications attached to the climate instance, whose contents should be modified by adding (or removing) CLASP specifications
336
+ # @return (::Array) The specifications
337
+ attr_reader :specifications
338
+ # [DEPRECATED] Instead, use +specifications+
339
+ def aliases; specifications; end
338
340
  # Indicates whether exit will be called (with non-zero exit code) when a
339
341
  # required command-line option is missing
340
342
  # @return (boolean)
@@ -400,7 +402,7 @@ class Climate
400
402
 
401
403
  raise ArgumentError, "argv may not be nil" if argv.nil?
402
404
 
403
- arguments = CLASP::Arguments.new argv, aliases
405
+ arguments = CLASP::Arguments.new argv, specifications
404
406
  flags = arguments.flags
405
407
  options = arguments.options
406
408
  values = arguments.values.to_a
@@ -430,7 +432,7 @@ class Climate
430
432
 
431
433
  flags.each do |f|
432
434
 
433
- al = aliases.detect do |a|
435
+ al = specifications.detect do |a|
434
436
 
435
437
  a.kind_of?(::CLASP::Flag) && f.name == a.name
436
438
  end
@@ -492,7 +494,7 @@ class Climate
492
494
 
493
495
  options.each do |o|
494
496
 
495
- al = aliases.detect do |a|
497
+ al = specifications.detect do |a|
496
498
 
497
499
  a.kind_of?(::CLASP::Option) && o.name == a.name
498
500
  end
@@ -555,16 +557,16 @@ class Climate
555
557
 
556
558
  # now police any required options
557
559
 
558
- required_aliases = aliases.select do |a|
560
+ required_specifications = specifications.select do |a|
559
561
 
560
562
  a.kind_of?(::CLASP::Option) && a.required?
561
563
  end
562
564
 
563
- required_aliases = Hash[required_aliases.map { |a| [ a.name, a ] }]
565
+ required_specifications = Hash[required_specifications.map { |a| [ a.name, a ] }]
564
566
 
565
567
  given_options = Hash[results[:options][:given].map { |o| [ o.name, o ]}]
566
568
 
567
- required_aliases.each do |k, a|
569
+ required_specifications.each do |k, a|
568
570
 
569
571
  unless given_options.has_key? k
570
572
 
@@ -720,7 +722,7 @@ class Climate
720
722
  msg
721
723
  end
722
724
 
723
- # Adds a flag to +aliases+
725
+ # Adds a flag to +specifications+
724
726
  #
725
727
  # === Signature
726
728
  #
@@ -729,24 +731,24 @@ class Climate
729
731
  # - +options+:: An options hash, containing any of the following options.
730
732
  #
731
733
  # * *Options*
732
- # - +:help+::
733
- # - +:alias+::
734
- # - +:aliases+::
735
- # - +:extras+::
734
+ # - +:help+::
735
+ # - +:alias+::
736
+ # - +:specifications+::
737
+ # - +:extras+::
736
738
  def add_flag(name_or_flag, options={}, &block)
737
739
 
738
740
  check_parameter name_or_flag, 'name_or_flag', allow_nil: false, types: [ ::String, ::Symbol, ::CLASP::Flag ]
739
741
 
740
742
  if ::CLASP::Flag === name_or_flag
741
743
 
742
- aliases << name_or_flag
744
+ specifications << name_or_flag
743
745
  else
744
746
 
745
- aliases << CLASP.Flag(name_or_flag, **options, &block)
747
+ specifications << CLASP.Flag(name_or_flag, **options, &block)
746
748
  end
747
749
  end
748
750
 
749
- # Adds an option to +aliases+
751
+ # Adds an option to +specifications+
750
752
  #
751
753
  # === Signature
752
754
  #
@@ -755,42 +757,42 @@ class Climate
755
757
  # - +options+:: An options hash, containing any of the following options.
756
758
  #
757
759
  # * *Options*
758
- # - +:alias+::
759
- # - +:aliases+::
760
- # - +:help+::
761
- # - +:values_range+::
762
- # - +:default_value+::
763
- # - +:extras+::
760
+ # - +:alias+::
761
+ # - +:specifications+::
762
+ # - +:help+::
763
+ # - +:values_range+::
764
+ # - +:default_value+::
765
+ # - +:extras+::
764
766
  def add_option(name_or_option, options={}, &block)
765
767
 
766
768
  check_parameter name_or_option, 'name_or_option', allow_nil: false, types: [ ::String, ::Symbol, ::CLASP::Option ]
767
769
 
768
770
  if ::CLASP::Option === name_or_option
769
771
 
770
- aliases << name_or_option
772
+ specifications << name_or_option
771
773
  else
772
774
 
773
- aliases << CLASP.Option(name_or_option, **options, &block)
775
+ specifications << CLASP.Option(name_or_option, **options, &block)
774
776
  end
775
777
  end
776
778
 
777
- # Adds an alias to +aliases+
779
+ # Adds an alias to +specifications+
778
780
  #
779
781
  # === Signature
780
782
  #
781
783
  # * *Parameters*
782
- # - +name_or_alias+:: The flag/option name or the valued option
784
+ # - +name_or_specification+:: The flag/option name or the valued option
783
785
  # - +aliases+:: One or more aliases
784
786
  #
785
787
  # === Examples
786
788
  #
787
- # ==== Alias(es) of a flag (single statement)
789
+ # ==== Specification(s) of a flag (single statement)
788
790
  #
789
791
  # +climate.add_flag('--mark-missing', alias: '-x')+
790
792
  #
791
793
  # +climate.add_flag('--absolute-path', aliases: [ '-abs', '-p' ])+
792
794
  #
793
- # ==== Alias(es) of a flag (multiple statements)
795
+ # ==== Specification(s) of a flag (multiple statements)
794
796
  #
795
797
  # +climate.add_flag('--mark-missing')+
796
798
  # +climate.add_alias('--mark-missing', '-x')+
@@ -798,35 +800,35 @@ class Climate
798
800
  # +climate.add_flag('--absolute-path')+
799
801
  # +climate.add_alias('--absolute-path', '-abs', '-p')+
800
802
  #
801
- # ==== Alias(es) of an option (single statement)
803
+ # ==== Specification(s) of an option (single statement)
802
804
  #
803
805
  # +climate.add_option('--add-patterns', alias: '-p')+
804
806
  #
805
- # ==== Alias(es) of an option (multiple statements)
807
+ # ==== Specification(s) of an option (multiple statements)
806
808
  #
807
809
  # +climate.add_option('--add-patterns')+
808
810
  # +climate.add_alias('--add-patterns', '-p')+
809
811
  #
810
- # ==== Alias of a valued option (which has to be multiple statements)
812
+ # ==== Specification of a valued option (which has to be multiple statements)
811
813
  #
812
814
  # +climate.add_option('--verbosity')+
813
815
  # +climate.add_alias('--verbosity=succinct', '-s')+
814
816
  # +climate.add_alias('--verbosity=verbose', '-v')+
815
- def add_alias(name_or_alias, *aliases)
817
+ def add_alias(name_or_specification, *aliases)
816
818
 
817
- check_parameter name_or_alias, 'name_or_alias', allow_nil: false, types: [ ::String, ::Symbol, ::CLASP::Flag, ::CLASP::Option ]
819
+ check_parameter name_or_specification, 'name_or_specification', allow_nil: false, types: [ ::String, ::Symbol, ::CLASP::Flag, ::CLASP::Option ]
818
820
  raise ArgumentError, "must supply at least one alias" if aliases.empty?
819
821
 
820
- case name_or_alias
822
+ case name_or_specification
821
823
  when ::CLASP::Flag
822
824
 
823
- self.aliases << name_or_alias
825
+ self.specifications << name_or_specification
824
826
  when ::CLASP::Option
825
827
 
826
- self.aliases << name_or_alias
828
+ self.specifications << name_or_specification
827
829
  else
828
830
 
829
- self.aliases << CLASP.Alias(name_or_alias, aliases: aliases)
831
+ self.specifications << CLASP.Alias(name_or_specification, aliases: aliases)
830
832
  end
831
833
  end
832
834
  end # class Climate
@@ -4,7 +4,7 @@
4
4
  # Purpose: Version for libclimate.Ruby library
5
5
  #
6
6
  # Created: 13th July 2015
7
- # Updated: 12th March 2019
7
+ # Updated: 12th April 2019
8
8
  #
9
9
  # Home: http://github.com/synesissoftware/libCLImate.Ruby
10
10
  #
@@ -43,7 +43,7 @@
43
43
  module LibCLImate
44
44
 
45
45
  # Current version of the libCLImate.Ruby library
46
- VERSION = '0.11.0'
46
+ VERSION = '0.12.0'
47
47
 
48
48
  private
49
49
  VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  #############################################################################
4
- # File: test/scratch/aliases.rb
4
+ # File: test/scratch/specifications.rb
5
5
  #
6
- # Purpose: Demonstrates use of aliases in options and flags
6
+ # Purpose: Demonstrates use of specifications in options and flags
7
7
  #
8
8
  # Created: 7th February 2018
9
9
  # Updated: 7th February 2018
@@ -22,10 +22,10 @@ require 'libclimate'
22
22
  # ##########################################################
23
23
  # constants
24
24
 
25
- PROGRAM_VER_MAJOR = 0
26
- PROGRAM_VER_MINOR = 1
27
- PROGRAM_VER_REVISION = 1
28
- PROGRAM_VER_BUILD = 1
25
+ PROGRAM_VER_MAJOR = 0
26
+ PROGRAM_VER_MINOR = 1
27
+ PROGRAM_VER_PATCH = 2
28
+ PROGRAM_VER_BUILD = 1
29
29
 
30
30
  # ##########################################################
31
31
  # command-line parsing
@@ -43,7 +43,15 @@ r = LibCLImate::Climate.new do |cl|
43
43
  cl.info_lines = [
44
44
 
45
45
  :version,
46
- 'demonstrates use of aliases',
46
+ 'demonstrates use of specifications',
47
+ ]
48
+
49
+ cl.version = [
50
+
51
+ PROGRAM_VER_MAJOR,
52
+ PROGRAM_VER_MINOR,
53
+ PROGRAM_VER_PATCH,
54
+ PROGRAM_VER_BUILD,
47
55
  ]
48
56
  end.run
49
57
 
@@ -371,7 +371,7 @@ class Test_Climate_minimal < Test::Unit::TestCase
371
371
  climate.add_option('--verbosity', alias: '-v', help: 'determines level of verbose operation', required: true)
372
372
  end
373
373
 
374
- assert climate.aliases[2].required?
374
+ assert climate.specifications[2].required?
375
375
 
376
376
  r = climate.run %w{ -v 2 }
377
377
 
@@ -418,7 +418,7 @@ class Test_Climate_minimal < Test::Unit::TestCase
418
418
 
419
419
  r = climate.run %w{ }
420
420
 
421
- assert climate.aliases[2].required?
421
+ assert climate.specifications[2].required?
422
422
 
423
423
  assert_not_nil r
424
424
  assert_kind_of ::Hash, r
@@ -468,7 +468,7 @@ class Test_Climate_minimal < Test::Unit::TestCase
468
468
 
469
469
  r = climate.run %w{ }
470
470
 
471
- assert climate.aliases[2].required?
471
+ assert climate.specifications[2].required?
472
472
 
473
473
  assert_not_nil r
474
474
  assert_kind_of ::Hash, r
@@ -518,7 +518,7 @@ class Test_Climate_minimal < Test::Unit::TestCase
518
518
 
519
519
  r = climate.run %w{ }
520
520
 
521
- assert climate.aliases[2].required?
521
+ assert climate.specifications[2].required?
522
522
 
523
523
  assert_not_nil r
524
524
  assert_kind_of ::Hash, r
@@ -223,8 +223,8 @@ class Test_Climate_minimal_CLASP < Test::Unit::TestCase
223
223
 
224
224
  bl = false#proc { is_verbose = true }
225
225
 
226
- climate.aliases << CLASP.Flag('--succinct', alias: '-s', help: 'operates succinctly')
227
- climate.aliases << CLASP.Flag('--verbose', alias: '-v', help: 'operates verbosely', extras: { :handle => proc { is_verbose = true }})
226
+ climate.add_flag('--succinct', alias: '-s', help: 'operates succinctly')
227
+ climate.add_flag('--verbose', alias: '-v', help: 'operates verbosely', extras: { :handle => proc { is_verbose = true }})
228
228
  end
229
229
 
230
230
  argv = %w{ --help --verbose --succinct }
@@ -281,7 +281,7 @@ class Test_Climate_minimal_CLASP < Test::Unit::TestCase
281
281
  climate.stdout = str
282
282
  climate.exit_on_usage = false
283
283
 
284
- climate.aliases << CLASP.Flag('--verbose', alias: '-v', help: 'operates verbosely', extras: { handle: proc { is_verbose = true }})
284
+ climate.add_flag('--verbose', alias: '-v', help: 'operates verbosely', extras: { handle: proc { is_verbose = true }})
285
285
  end
286
286
 
287
287
  argv = %w{ --verbose }
@@ -325,7 +325,7 @@ class Test_Climate_minimal_CLASP < Test::Unit::TestCase
325
325
  climate.stdout = str
326
326
  climate.exit_on_usage = false
327
327
 
328
- climate.aliases << CLASP.Option('--verbosity', alias: '-v', help: 'determines level of verbose operation', extras: { handle: proc { |o| verbosity = o.value }})
328
+ climate.add_option('--verbosity', alias: '-v', help: 'determines level of verbose operation', extras: { handle: proc { |o| verbosity = o.value }})
329
329
  end
330
330
 
331
331
  argv = %w{ -v 2 }
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # test aliases
3
+ # test specifications
4
4
 
5
5
  $:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
6
6
 
@@ -15,7 +15,7 @@ require 'stringio'
15
15
 
16
16
  class Test_Climate_minimal < Test::Unit::TestCase
17
17
 
18
- def test_option_with_flag_aliases
18
+ def test_option_with_flag_specifications
19
19
 
20
20
  options = {}
21
21
 
@@ -44,7 +44,7 @@ class Test_Climate_minimal < Test::Unit::TestCase
44
44
  assert_equal 'action1', options[:action]
45
45
  end
46
46
 
47
- # invoke via option alias
47
+ # invoke via option specification
48
48
  begin
49
49
  options = {}
50
50
 
@@ -57,7 +57,7 @@ class Test_Climate_minimal < Test::Unit::TestCase
57
57
  assert_equal 'action2', options[:action]
58
58
  end
59
59
 
60
- # invoke via flag alias
60
+ # invoke via flag specification
61
61
  begin
62
62
  options = {}
63
63
 
@@ -70,7 +70,7 @@ class Test_Climate_minimal < Test::Unit::TestCase
70
70
  assert_equal 'change', options[:action]
71
71
  end
72
72
 
73
- # invoke via flag alias
73
+ # invoke via flag specification
74
74
  begin
75
75
  options = {}
76
76
 
@@ -21,7 +21,7 @@ class Test_Climate_with_blocks_CLASP < Test::Unit::TestCase
21
21
 
22
22
  climate = LibCLImate::Climate.new do |climate|
23
23
 
24
- climate.aliases << CLASP.Flag('--verbose') { is_verbose = true }
24
+ climate.add_flag('--verbose') { is_verbose = true }
25
25
  end
26
26
 
27
27
  argv = %w{ --verbose }
@@ -37,7 +37,7 @@ class Test_Climate_with_blocks_CLASP < Test::Unit::TestCase
37
37
 
38
38
  climate = LibCLImate::Climate.new do |climate|
39
39
 
40
- climate.aliases << CLASP.Option('--flavour') { |o| flavour = o.value }
40
+ climate.add_option('--flavour') { |o| flavour = o.value }
41
41
  end
42
42
 
43
43
  argv = %w{ --flavour=blueberry }
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libclimate-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Wilson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-19 00:00:00.000000000 Z
11
+ date: 2019-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clasp-ruby
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.15'
19
+ version: '0.18'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.15'
26
+ version: '0.18'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: xqsr3
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.31'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.31'
41
41
  description: |2+
@@ -45,26 +45,30 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - LICENSE
49
+ - README.md
50
+ - examples/flag_and_option_specifications.md
51
+ - examples/flag_and_option_specifications.rb
52
+ - examples/show_usage_and_version.md
53
+ - examples/show_usage_and_version.rb
54
+ - lib/libclimate.rb
48
55
  - lib/libclimate/climate.rb
49
56
  - lib/libclimate/libclimate.rb
50
57
  - lib/libclimate/version.rb
51
- - lib/libclimate.rb
52
- - test/scratch/aliases.rb
53
58
  - test/scratch/blankzeroes.rb
59
+ - test/scratch/specifications.rb
54
60
  - test/unit/tc_abort.rb
55
61
  - test/unit/tc_infer_version.rb
56
62
  - test/unit/tc_minimal.rb
57
63
  - test/unit/tc_minimal_CLASP.rb
58
- - test/unit/tc_test_aliases.rb
64
+ - test/unit/tc_test_specifications.rb
59
65
  - test/unit/tc_values.rb
60
66
  - test/unit/tc_with_blocks.rb
61
67
  - test/unit/tc_with_blocks_CLASP.rb
62
68
  - test/unit/ts_all.rb
63
- - README.md
64
- - LICENSE
65
69
  homepage: http://www.libclimate.org/
66
70
  licenses:
67
- - Modified BSD
71
+ - BSD-3-Clause
68
72
  metadata: {}
69
73
  post_install_message:
70
74
  rdoc_options: []
@@ -72,17 +76,17 @@ require_paths:
72
76
  - lib
73
77
  required_ruby_version: !ruby/object:Gem::Requirement
74
78
  requirements:
75
- - - ~>
79
+ - - "~>"
76
80
  - !ruby/object:Gem::Version
77
81
  version: '2.0'
78
82
  required_rubygems_version: !ruby/object:Gem::Requirement
79
83
  requirements:
80
- - - '>='
84
+ - - ">="
81
85
  - !ruby/object:Gem::Version
82
86
  version: '0'
83
87
  requirements: []
84
88
  rubyforge_project:
85
- rubygems_version: 2.0.14.1
89
+ rubygems_version: 2.2.5
86
90
  signing_key:
87
91
  specification_version: 4
88
92
  summary: libCLImate.Ruby