libclimate-ruby 0.17.0.1 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +23 -21
- data/README.md +57 -30
- data/examples/flag_and_option_specifications.from_DATA.md +29 -29
- data/examples/flag_and_option_specifications.md +45 -45
- data/examples/show_usage_and_version.md +16 -16
- data/lib/libclimate/climate.rb +5 -4
- data/lib/libclimate/version.rb +3 -3
- data/test/scratch/blankzeroes.rb +2 -2
- data/test/unit/tc_abort.rb +1 -1
- data/test/unit/tc_double_slash_index.rb +1 -1
- data/test/unit/tc_infer_version.rb +1 -1
- data/test/unit/tc_minimal.rb +1 -1
- data/test/unit/tc_minimal_CLASP.rb +1 -1
- data/test/unit/tc_parse.rb +1 -1
- data/test/unit/tc_parse_and_verify.rb +81 -1
- data/test/unit/tc_test_specifications.rb +1 -1
- data/test/unit/tc_values.rb +2 -1
- data/test/unit/tc_with_blocks.rb +1 -1
- data/test/unit/tc_with_blocks_CLASP.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c1014739a5918db9efeb5135cf15f993bdd7ef3e09192661b9ea204ff56162f0
|
|
4
|
+
data.tar.gz: 74d345f4b3bb769d416b0a13adf6483810855426b7fcc38a78fc62086b391b9e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 622c85547fcf19727ee1fda68455440791001652d4d29d323f051061ac426b493aecab3cd7be8bb89b53403aa53a397b83139d5228b854eff577443597a5a463
|
|
7
|
+
data.tar.gz: c55439ac1104533836c03f9a786d1a2ab80677a4a8b3947ea46ffb103ac81686906ddcc910a8c80bd43247b974a672ce8dd8219614a7098d7786bc012c0c869c
|
data/LICENSE
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
libCLImate.Ruby
|
|
1
|
+
libCLImate.Ruby - BSD 3-Clause License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2016-2026, Matthew Wilson and Synesis Information Systems
|
|
4
|
+
Copyright (c) 2015-2019, Matthew Wilson and Synesis Software
|
|
4
5
|
All rights reserved.
|
|
5
6
|
|
|
6
7
|
Redistribution and use in source and binary forms, with or without
|
|
7
8
|
modification, are permitted provided that the following conditions are met:
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
14
|
+
this list of conditions and the following disclaimer in the documentation
|
|
15
|
+
and/or other materials provided with the distribution.
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
18
|
+
contributors may be used to endorse or promote products derived from
|
|
19
|
+
this software without specific prior written permission.
|
|
20
|
+
|
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
22
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
23
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
24
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
25
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
26
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
27
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
28
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
29
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
30
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
31
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
20
32
|
|
|
21
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
23
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
24
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
25
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
26
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
27
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
28
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
29
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
30
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
|
-
# libCLImate.Ruby
|
|
1
|
+
# libCLImate.Ruby <!-- omit in toc -->
|
|
2
|
+
|
|
2
3
|
libCLImate, for Ruby
|
|
3
4
|
|
|
5
|
+

|
|
6
|
+
[](https://opensource.org/licenses/BSD-3-Clause)
|
|
4
7
|
[](https://badge.fury.io/rb/libclimate-ruby)
|
|
8
|
+
[](https://rubygems.org/gems/libclimate-ruby)
|
|
9
|
+
[](https://github.com/synesissoftware/libCLImate.Ruby/releases/latest)
|
|
10
|
+
[](https://github.com/synesissoftware/libCLImate.Ruby/commits/master)
|
|
11
|
+
|
|
5
12
|
|
|
6
|
-
## Table of Contents
|
|
13
|
+
## Table of Contents <!-- omit in toc -->
|
|
14
|
+
|
|
15
|
+
- [Introduction](#introduction)
|
|
16
|
+
- [Installation](#installation)
|
|
17
|
+
- [Components](#components)
|
|
18
|
+
- [Examples](#examples)
|
|
19
|
+
- [Project Information](#project-information)
|
|
20
|
+
- [Where to get help](#where-to-get-help)
|
|
21
|
+
- [Contribution guidelines](#contribution-guidelines)
|
|
22
|
+
- [Dependencies](#dependencies)
|
|
23
|
+
- [Related projects](#related-projects)
|
|
24
|
+
- [License](#license)
|
|
7
25
|
|
|
8
|
-
1. [Introduction](#introduction)
|
|
9
|
-
2. [Installation](#installation)
|
|
10
|
-
3. [Components](#components)
|
|
11
|
-
4. [Examples](#examples)
|
|
12
|
-
5. [Project Information](#project-information)
|
|
13
26
|
|
|
14
27
|
## Introduction
|
|
15
28
|
|
|
@@ -22,12 +35,13 @@ libCLImate, for Ruby
|
|
|
22
35
|
|
|
23
36
|
**libCLImate.Ruby** is the Ruby version.
|
|
24
37
|
|
|
38
|
+
|
|
25
39
|
## Installation
|
|
26
40
|
|
|
27
41
|
Install via **gem** as in:
|
|
28
42
|
|
|
29
43
|
```
|
|
30
|
-
|
|
44
|
+
gem install libclimate-ruby
|
|
31
45
|
```
|
|
32
46
|
|
|
33
47
|
or add it to your `Gemfile`.
|
|
@@ -38,67 +52,76 @@ Use via **require**, as in:
|
|
|
38
52
|
require 'libclimate'
|
|
39
53
|
```
|
|
40
54
|
|
|
55
|
+
|
|
41
56
|
## Components
|
|
42
57
|
|
|
43
|
-
In common with several other variants of **libCLImate**, **libCLImate.Ruby** revolves around a ``Climate``
|
|
58
|
+
In common with several other variants of **libCLImate**, **libCLImate.Ruby** revolves around a ``Climate`` class whose initialiser takes a block and acts as a lightweight DSL for concise definition of a command-line parsing instance, as in:
|
|
44
59
|
|
|
45
60
|
```Ruby
|
|
46
61
|
options = {}
|
|
47
62
|
climate = LibCLImate::Climate.new do |cl|
|
|
48
63
|
|
|
49
|
-
|
|
64
|
+
cl.add_flag('--debug', alias: '-d', help: 'runs in Debug mode') do
|
|
50
65
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
66
|
+
options[:debug] = true
|
|
67
|
+
end
|
|
68
|
+
cl.add_option('--verbosity', alias: '-v', help: 'specifies the verbosity', values: [ 'terse', 'quiet', 'silent', 'chatty' ]) do |o, sp|
|
|
54
69
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
options[:verbosity] = o.value
|
|
71
|
+
end
|
|
72
|
+
cl.add_alias('--verbosity=chatty', '-c')
|
|
58
73
|
|
|
59
|
-
|
|
74
|
+
cl.version = [ 0, 1, 0 ]
|
|
60
75
|
|
|
61
|
-
|
|
76
|
+
cl.info_lines = [
|
|
62
77
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
'libCLImate.Ruby examples',
|
|
79
|
+
:version,
|
|
80
|
+
"Illustrates use of libCLImate.Ruby's specification of flags, options, and specifications",
|
|
81
|
+
'',
|
|
82
|
+
]
|
|
68
83
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
84
|
+
cl.constrain_values = 1..2
|
|
85
|
+
cl.usage_values = "<dir-1> [ <dir-2> ]"
|
|
86
|
+
cl.value_names = [
|
|
72
87
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
88
|
+
"first directory",
|
|
89
|
+
"second directory",
|
|
90
|
+
]
|
|
76
91
|
end
|
|
77
92
|
```
|
|
78
93
|
|
|
94
|
+
|
|
79
95
|
## Examples
|
|
80
96
|
|
|
81
97
|
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).
|
|
82
98
|
|
|
83
99
|
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).
|
|
84
100
|
|
|
101
|
+
|
|
85
102
|
## Project Information
|
|
86
103
|
|
|
104
|
+
|
|
87
105
|
### Where to get help
|
|
88
106
|
|
|
89
107
|
[GitHub Page](https://github.com/synesissoftware/libCLImate.Ruby "GitHub Page")
|
|
90
108
|
|
|
109
|
+
|
|
91
110
|
### Contribution guidelines
|
|
92
111
|
|
|
93
112
|
Defect reports, feature requests, and pull requests are welcome on https://github.com/synesissoftware/libCLImate.Ruby.
|
|
94
113
|
|
|
114
|
+
|
|
95
115
|
### Dependencies
|
|
96
116
|
|
|
97
|
-
|
|
117
|
+
This library has efferent dependencies on:
|
|
98
118
|
|
|
99
119
|
* the [**CLASP.Ruby**](https://github.com/synesissoftware/CLASP.Ruby) library; and
|
|
100
120
|
* the [**xqsr3**](https://github.com/synesissoftware/xqsr3) library.
|
|
101
121
|
|
|
122
|
+
It has no known afferent dependencies.
|
|
123
|
+
|
|
124
|
+
|
|
102
125
|
### Related projects
|
|
103
126
|
|
|
104
127
|
* [**CLASP**](https://github.com/synesissoftware/CLASP/)
|
|
@@ -108,9 +131,13 @@ Defect reports, feature requests, and pull requests are welcome on https://githu
|
|
|
108
131
|
* [**CLASP.Python**](https://github.com/synesissoftware/CLASP.Python/)
|
|
109
132
|
* [**CLASP.Ruby**](https://github.com/synesissoftware/CLASP.Ruby/)
|
|
110
133
|
* [**libCLImate** (C/C++)](https://github.com/synesissoftware/libCLImate)
|
|
134
|
+
* [**libCLImate.Go** (Go)](https://github.com/synesissoftware/libCLImate.Go)
|
|
111
135
|
* [**xqsr3**](https://github.com/synesissoftware.com/libCLImate.Ruby-xml/)
|
|
112
136
|
|
|
137
|
+
|
|
113
138
|
### License
|
|
114
139
|
|
|
115
140
|
**libCLImate.Ruby** is released under the 3-clause BSD license. See [LICENSE](./LICENSE) for details.
|
|
116
141
|
|
|
142
|
+
|
|
143
|
+
<!-- ########################### end of file ########################### -->
|
|
@@ -22,9 +22,9 @@ require 'libclimate'
|
|
|
22
22
|
options = {}
|
|
23
23
|
climate = LibCLImate::Climate.load DATA do |cl|
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
cl.on_flag('--debug') { options[:debug] = true }
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
cl.on_option('--verbosity') { |o, a| options[:verbosity] = o.value }
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
r = climate.parse_and_verify ARGV
|
|
@@ -34,12 +34,12 @@ r = climate.parse_and_verify ARGV
|
|
|
34
34
|
|
|
35
35
|
if options[:verbosity]
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
$stdout.puts "verbosity is specified as: #{options[:verbosity]}"
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
if options[:debug]
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
$stdout.puts 'Debug mode is specified'
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
|
|
@@ -93,20 +93,20 @@ libclimate:
|
|
|
93
93
|
|
|
94
94
|
## Usage
|
|
95
95
|
|
|
96
|
-
NOTE: in order to demonstrate fully the utility of the *loading-from-source-file-YAML* facility, I've added a constraint for 1-2 values - notionally directories -
|
|
96
|
+
NOTE: in order to demonstrate fully the utility of the *loading-from-source-file-YAML* facility, I've added a constraint for 1-2 values - notionally directories -
|
|
97
97
|
|
|
98
98
|
### No arguments
|
|
99
99
|
|
|
100
100
|
If executed with no arguments
|
|
101
101
|
|
|
102
102
|
```
|
|
103
|
-
|
|
103
|
+
ruby examples/flag_and_option_specifications.from_DATA.rb
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
or (in a Unix shell):
|
|
107
107
|
|
|
108
108
|
```
|
|
109
|
-
|
|
109
|
+
./examples/flag_and_option_specifications.from_DATA.rb
|
|
110
110
|
```
|
|
111
111
|
|
|
112
112
|
it gives the output (with an exit code of **1**):
|
|
@@ -121,7 +121,7 @@ flag_and_option_specifications.from_DATA(.rb): first directory not specified; us
|
|
|
121
121
|
If executed with the arguments
|
|
122
122
|
|
|
123
123
|
```
|
|
124
|
-
|
|
124
|
+
ruby examples/flag_and_option_specifications.from_DATA.rb --help
|
|
125
125
|
```
|
|
126
126
|
|
|
127
127
|
it gives the output:
|
|
@@ -135,26 +135,26 @@ USAGE: flag_and_option_specifications.from_DATA(.rb) [... flags/options ...] <di
|
|
|
135
135
|
|
|
136
136
|
flags/options:
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
--help
|
|
139
|
+
shows this help and terminates
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
--version
|
|
142
|
+
shows version and terminates
|
|
143
143
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
-d
|
|
145
|
+
--debug
|
|
146
|
+
runs in Debug mode
|
|
147
147
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
148
|
+
--chatty --verbosity=chatty
|
|
149
|
+
-c --verbosity=chatty
|
|
150
|
+
--verbosity=<value>
|
|
151
|
+
specifies the verbosity
|
|
152
|
+
where <value> one of:
|
|
153
|
+
silent
|
|
154
|
+
quiet
|
|
155
|
+
terse
|
|
156
|
+
chatty
|
|
157
|
+
verbose
|
|
158
158
|
|
|
159
159
|
```
|
|
160
160
|
|
|
@@ -163,7 +163,7 @@ flags/options:
|
|
|
163
163
|
If executed with the arguments
|
|
164
164
|
|
|
165
165
|
```
|
|
166
|
-
|
|
166
|
+
ruby examples/flag_and_option_specifications.from_DATA.rb dir-1 dir-2 --debug --verbosity=silent
|
|
167
167
|
```
|
|
168
168
|
|
|
169
169
|
it gives the output:
|
|
@@ -179,7 +179,7 @@ processing in 'dir-1' and 'dir-2'
|
|
|
179
179
|
If executed with the arguments
|
|
180
180
|
|
|
181
181
|
```
|
|
182
|
-
|
|
182
|
+
ruby examples/flag_and_option_specifications.from_DATA.rb dir-1 dir-2 -v silent -d
|
|
183
183
|
```
|
|
184
184
|
|
|
185
185
|
it gives the (same) output:
|
|
@@ -195,7 +195,7 @@ processing in 'dir-1' and 'dir-2'
|
|
|
195
195
|
If executed with the arguments
|
|
196
196
|
|
|
197
197
|
```
|
|
198
|
-
|
|
198
|
+
ruby examples/flag_and_option_specifications.from_DATA.rb dir-1 dir-2 -c -d
|
|
199
199
|
```
|
|
200
200
|
|
|
201
201
|
it gives the output:
|
|
@@ -211,7 +211,7 @@ processing in 'dir-1' and 'dir-2'
|
|
|
211
211
|
If executed with the arguments
|
|
212
212
|
|
|
213
213
|
```
|
|
214
|
-
|
|
214
|
+
ruby examples/flag_and_option_specifications.from_DATA.rb dir-1 dir-2 -dc
|
|
215
215
|
```
|
|
216
216
|
|
|
217
217
|
it gives the (same) output:
|
|
@@ -20,33 +20,33 @@ require 'libclimate'
|
|
|
20
20
|
options = {}
|
|
21
21
|
climate = LibCLImate::Climate.new do |cl|
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
cl.add_flag('--debug', alias: '-d', help: 'runs in Debug mode') do
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
options[:verbosity] = o.value
|
|
30
|
+
end
|
|
31
|
+
cl.add_alias('--verbosity=chatty', '-c')
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
cl.version = [ 0, 1, 0 ]
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
cl.info_lines = [
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
'libCLImate.Ruby examples',
|
|
38
|
+
:version,
|
|
39
|
+
"Illustrates use of libCLImate.Ruby's specification of flags, options, and specifications",
|
|
40
|
+
'',
|
|
41
|
+
]
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
cl.constrain_values = 1..2
|
|
44
|
+
cl.usage_values = "<dir-1> [ <dir-2> ]"
|
|
45
|
+
cl.value_names = [
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
"first directory",
|
|
48
|
+
"second directory",
|
|
49
|
+
]
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
r = climate.parse_and_verify ARGV
|
|
@@ -57,12 +57,12 @@ r = climate.parse_and_verify ARGV
|
|
|
57
57
|
|
|
58
58
|
if options[:verbosity]
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
$stdout.puts "verbosity is specified as: #{options[:verbosity]}"
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
if options[:debug]
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
$stdout.puts 'Debug mode is specified'
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
# some notional output
|
|
@@ -77,13 +77,13 @@ $stdout.puts "processing in '#{r.values[0]}'" + (r.values.size > 1 ? " and '#{r.
|
|
|
77
77
|
If executed with no arguments
|
|
78
78
|
|
|
79
79
|
```
|
|
80
|
-
|
|
80
|
+
ruby examples/flag_and_option_specifications.rb
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
or (in a Unix shell):
|
|
84
84
|
|
|
85
85
|
```
|
|
86
|
-
|
|
86
|
+
./examples/flag_and_option_specifications.rb
|
|
87
87
|
```
|
|
88
88
|
|
|
89
89
|
it gives the output:
|
|
@@ -97,7 +97,7 @@ flag_and_option_specifications(.rb): first directory not specified; use --help f
|
|
|
97
97
|
If executed with the arguments
|
|
98
98
|
|
|
99
99
|
```
|
|
100
|
-
|
|
100
|
+
ruby examples/flag_and_option_specifications.rb --help
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
it gives the output:
|
|
@@ -111,25 +111,25 @@ USAGE: flag_and_option_specifications.rb [ ... flags and options ... ]
|
|
|
111
111
|
|
|
112
112
|
flags/options:
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
-d
|
|
115
|
+
--debug
|
|
116
|
+
runs in Debug mode
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
118
|
+
-c --verbosity=chatty
|
|
119
|
+
-v <value>
|
|
120
|
+
--verbosity=<value>
|
|
121
|
+
specifies the verbosity
|
|
122
|
+
where <value> one of:
|
|
123
|
+
terse
|
|
124
|
+
quiet
|
|
125
|
+
silent
|
|
126
|
+
chatty
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
--help
|
|
129
|
+
Shows usage and terminates
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
--version
|
|
132
|
+
Shows version and terminates
|
|
133
133
|
```
|
|
134
134
|
|
|
135
135
|
### Specify flags and options in long-form
|
|
@@ -137,7 +137,7 @@ flags/options:
|
|
|
137
137
|
If executed with the arguments
|
|
138
138
|
|
|
139
139
|
```
|
|
140
|
-
|
|
140
|
+
ruby examples/flag_and_option_specifications.rb dir-1 dir-2 --debug --verbosity=silent
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
it gives the output:
|
|
@@ -153,7 +153,7 @@ processing in 'dir-1' and 'dir-2'
|
|
|
153
153
|
If executed with the arguments
|
|
154
154
|
|
|
155
155
|
```
|
|
156
|
-
|
|
156
|
+
ruby examples/flag_and_option_specifications.rb dir-1 dir-2 -v silent -d
|
|
157
157
|
```
|
|
158
158
|
|
|
159
159
|
it gives the (same) output:
|
|
@@ -169,7 +169,7 @@ processing in 'dir-1' and 'dir-2'
|
|
|
169
169
|
If executed with the arguments
|
|
170
170
|
|
|
171
171
|
```
|
|
172
|
-
|
|
172
|
+
ruby examples/flag_and_option_specifications.rb -c -d dir-1 dir-2
|
|
173
173
|
```
|
|
174
174
|
|
|
175
175
|
it gives the output:
|
|
@@ -185,7 +185,7 @@ processing in 'dir-1' and 'dir-2'
|
|
|
185
185
|
If executed with the arguments
|
|
186
186
|
|
|
187
187
|
```
|
|
188
|
-
|
|
188
|
+
ruby examples/flag_and_option_specifications.rb -dc dir-1 dir-2
|
|
189
189
|
```
|
|
190
190
|
|
|
191
191
|
it gives the (same) output:
|
|
@@ -19,15 +19,15 @@ require 'libclimate'
|
|
|
19
19
|
|
|
20
20
|
climate = LibCLImate::Climate.new do |cl|
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
cl.version = [ 0, 1, 0 ]
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
cl.info_lines = [
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
'libCLImate.Ruby examples',
|
|
27
|
+
:version,
|
|
28
|
+
"Illustrates use of libCLImate.Ruby's automatic support for '--help' and '--version'",
|
|
29
|
+
'',
|
|
30
|
+
]
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
climate.parse_and_verify ARGV
|
|
@@ -44,13 +44,13 @@ $stdout.puts 'no flags specified'
|
|
|
44
44
|
If executed with no arguments
|
|
45
45
|
|
|
46
46
|
```
|
|
47
|
-
|
|
47
|
+
ruby examples/show_usage_and_version.rb
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
or (in a Unix shell):
|
|
51
51
|
|
|
52
52
|
```
|
|
53
|
-
|
|
53
|
+
./examples/show_usage_and_version.rb
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
it gives the output:
|
|
@@ -64,7 +64,7 @@ no flags specified
|
|
|
64
64
|
If executed with the arguments
|
|
65
65
|
|
|
66
66
|
```
|
|
67
|
-
|
|
67
|
+
ruby examples/show_usage_and_version.rb --help
|
|
68
68
|
```
|
|
69
69
|
|
|
70
70
|
it gives the output:
|
|
@@ -78,11 +78,11 @@ USAGE: show_usage_and_version.rb [ ... flags and options ... ]
|
|
|
78
78
|
|
|
79
79
|
flags/options:
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
--help
|
|
82
|
+
shows this help and terminates
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
--version
|
|
85
|
+
shows version and terminates
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
### Show version
|
|
@@ -90,7 +90,7 @@ flags/options:
|
|
|
90
90
|
If executed with the arguments
|
|
91
91
|
|
|
92
92
|
```
|
|
93
|
-
|
|
93
|
+
ruby examples/show_usage_and_version.rb --version
|
|
94
94
|
```
|
|
95
95
|
|
|
96
96
|
it gives the output:
|
|
@@ -104,7 +104,7 @@ show_usage_and_version.rb 0.1.0
|
|
|
104
104
|
If executed with the arguments
|
|
105
105
|
|
|
106
106
|
```
|
|
107
|
-
|
|
107
|
+
ruby examples/show_usage_and_version.rb --unknown=value
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
it gives the output (on the standard error stream):
|
data/lib/libclimate/climate.rb
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
# Purpose: Definition of the ::LibCLImate::Climate class
|
|
6
6
|
#
|
|
7
7
|
# Created: 13th July 2015
|
|
8
|
-
# Updated:
|
|
8
|
+
# Updated: 30th July 2026
|
|
9
9
|
#
|
|
10
10
|
# Home: http://github.com/synesissoftware/libCLImate.Ruby
|
|
11
11
|
#
|
|
12
12
|
# Author: Matthew Wilson
|
|
13
13
|
#
|
|
14
|
-
# Copyright (c) 2019-
|
|
14
|
+
# Copyright (c) 2019-2026, Matthew Wilson and Synesis Information Systems
|
|
15
15
|
# Copyright (c) 2015-2019, Matthew Wilson and Synesis Software
|
|
16
16
|
# All rights reserved.
|
|
17
17
|
#
|
|
@@ -264,7 +264,7 @@ class Climate
|
|
|
264
264
|
end
|
|
265
265
|
else
|
|
266
266
|
|
|
267
|
-
message = make_abort_message_("unrecognised flag '#{
|
|
267
|
+
message = climate.make_abort_message_("unrecognised flag '#{flag}'")
|
|
268
268
|
|
|
269
269
|
if false
|
|
270
270
|
|
|
@@ -312,7 +312,7 @@ class Climate
|
|
|
312
312
|
end
|
|
313
313
|
else
|
|
314
314
|
|
|
315
|
-
message = make_abort_message_("unrecognised option '#{
|
|
315
|
+
message = climate.make_abort_message_("unrecognised option '#{option}'")
|
|
316
316
|
|
|
317
317
|
if false
|
|
318
318
|
|
|
@@ -378,6 +378,7 @@ class Climate
|
|
|
378
378
|
GIVEN_SPECS_ = "_Given_Specs_01B59422_8407_4c89_9432_8160C52BD5AD"
|
|
379
379
|
end # module Climate_Constants_
|
|
380
380
|
|
|
381
|
+
public
|
|
381
382
|
def make_abort_message_(msg)
|
|
382
383
|
|
|
383
384
|
if 0 != (usage_help_suffix || 0).size
|
data/lib/libclimate/version.rb
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
# Purpose: Version for libclimate.Ruby library
|
|
5
5
|
#
|
|
6
6
|
# Created: 13th July 2015
|
|
7
|
-
# Updated:
|
|
7
|
+
# Updated: 30th July 2026
|
|
8
8
|
#
|
|
9
9
|
# Home: http://github.com/synesissoftware/libCLImate.Ruby
|
|
10
10
|
#
|
|
11
|
-
# Copyright (c) 2019-
|
|
11
|
+
# Copyright (c) 2019-2026, Matthew Wilson and Synesis Information Systems
|
|
12
12
|
# Copyright (c) 2015-2019, Matthew Wilson and Synesis Software
|
|
13
13
|
# All rights reserved.
|
|
14
14
|
#
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
module LibCLImate
|
|
45
45
|
|
|
46
46
|
# Current version of the libCLImate.Ruby library
|
|
47
|
-
VERSION = '0.17.
|
|
47
|
+
VERSION = '0.17.1'
|
|
48
48
|
|
|
49
49
|
private
|
|
50
50
|
VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
|
data/test/scratch/blankzeroes.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
#! /usr/bin/ruby
|
|
2
2
|
|
|
3
3
|
#############################################################################
|
|
4
4
|
# File: test/scratch/blankzeroes.rb
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# Purpose: This filter program converts 0 values in a TSV into blanks
|
|
7
7
|
#
|
|
8
8
|
# Created: 14th May 2016
|
|
9
|
-
# Updated:
|
|
9
|
+
# Updated: 30th July 2026
|
|
10
10
|
#
|
|
11
11
|
# Author: Matthew Wilson
|
|
12
12
|
#
|
data/test/unit/tc_abort.rb
CHANGED
data/test/unit/tc_minimal.rb
CHANGED
data/test/unit/tc_parse.rb
CHANGED
|
@@ -9,9 +9,9 @@ require 'libclimate'
|
|
|
9
9
|
|
|
10
10
|
require 'xqsr3/extensions/test/unit'
|
|
11
11
|
|
|
12
|
+
require 'stringio'
|
|
12
13
|
require 'test/unit'
|
|
13
14
|
|
|
14
|
-
require 'stringio'
|
|
15
15
|
|
|
16
16
|
class Test_Climate_parse_and_verify < Test::Unit::TestCase
|
|
17
17
|
|
|
@@ -156,5 +156,85 @@ class Test_Climate_parse_and_verify < Test::Unit::TestCase
|
|
|
156
156
|
climate.parse_and_verify argv, raise_on_required: MissingRequiredException
|
|
157
157
|
end
|
|
158
158
|
end
|
|
159
|
+
|
|
160
|
+
def test_unrecognized_flag_raises_unrecognised_argument_exception
|
|
161
|
+
|
|
162
|
+
stdout = StringIO.new
|
|
163
|
+
stderr = StringIO.new
|
|
164
|
+
|
|
165
|
+
climate = LibCLImate::Climate.new do |cl|
|
|
166
|
+
|
|
167
|
+
cl.stdout = $stdout
|
|
168
|
+
cl.stderr = $stderr
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
assert $stdout.equal? climate.stdout
|
|
172
|
+
assert $stderr.equal? climate.stderr
|
|
173
|
+
|
|
174
|
+
argv = [
|
|
175
|
+
|
|
176
|
+
'--unrecognised-flag',
|
|
177
|
+
]
|
|
178
|
+
|
|
179
|
+
assert_raise_with_message(UnrecognisedArgumentException, /unrecognised flag '--unrecognised-flag'/) do
|
|
180
|
+
|
|
181
|
+
climate.parse_and_verify argv, raise_on_unrecognised: UnrecognisedArgumentException
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def test_unrecognized_option_raises_unrecognised_argument_exception
|
|
186
|
+
|
|
187
|
+
stdout = StringIO.new
|
|
188
|
+
stderr = StringIO.new
|
|
189
|
+
|
|
190
|
+
climate = LibCLImate::Climate.new do |cl|
|
|
191
|
+
|
|
192
|
+
cl.stdout = $stdout
|
|
193
|
+
cl.stderr = $stderr
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
assert $stdout.equal? climate.stdout
|
|
197
|
+
assert $stderr.equal? climate.stderr
|
|
198
|
+
|
|
199
|
+
argv = [
|
|
200
|
+
|
|
201
|
+
'--unrecognised-option=some_value',
|
|
202
|
+
]
|
|
203
|
+
|
|
204
|
+
assert_raise_with_message(UnrecognisedArgumentException, /unrecognised option '--unrecognised-option=some_value'/) do
|
|
205
|
+
|
|
206
|
+
climate.parse_and_verify argv, raise_on_unrecognised: UnrecognisedArgumentException
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def test_add_flag_method_exists_and_is_callable
|
|
211
|
+
|
|
212
|
+
climate = LibCLImate::Climate.new {}
|
|
213
|
+
|
|
214
|
+
# Assert that calling add_flag does not raise an exception
|
|
215
|
+
assert_nothing_raised do
|
|
216
|
+
|
|
217
|
+
climate.add_flag('--test-flag')
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Verify that the flag is added to specifications
|
|
221
|
+
assert_equal 3, climate.specifications.size
|
|
222
|
+
assert_equal '--test-flag', climate.specifications[2].name
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def test_add_option_method_exists_and_is_callable
|
|
226
|
+
|
|
227
|
+
climate = LibCLImate::Climate.new {}
|
|
228
|
+
|
|
229
|
+
# Assert that calling add_option does not raise an exception
|
|
230
|
+
assert_nothing_raised do
|
|
231
|
+
|
|
232
|
+
climate.add_option('--test-option')
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
# Verify that the option is added to specifications
|
|
236
|
+
assert_equal 3, climate.specifications.size
|
|
237
|
+
assert_equal '--test-option', climate.specifications[2].name
|
|
238
|
+
end
|
|
159
239
|
end
|
|
160
240
|
|
data/test/unit/tc_values.rb
CHANGED
|
@@ -6,9 +6,10 @@ $:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
|
|
|
6
6
|
require 'libclimate'
|
|
7
7
|
|
|
8
8
|
require 'xqsr3/extensions/test/unit'
|
|
9
|
-
require 'test/unit'
|
|
10
9
|
|
|
11
10
|
require 'stringio'
|
|
11
|
+
require 'test/unit'
|
|
12
|
+
|
|
12
13
|
|
|
13
14
|
class Test_Climate_values_constraints < Test::Unit::TestCase
|
|
14
15
|
|
data/test/unit/tc_with_blocks.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: libclimate-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.17.
|
|
4
|
+
version: 0.17.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Wilson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-07-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: clasp-ruby
|