clasp-ruby 0.23.1 → 0.23.3
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/AUTHORS.md +21 -0
- data/CHANGES.md +313 -0
- data/CONTRIBUTING.md +36 -0
- data/EXAMPLES.md +11 -0
- data/FAQ.md +28 -0
- data/INSTALL.md +41 -0
- data/LICENSE +22 -21
- data/NEWS.md +65 -0
- data/README.md +83 -26
- data/Rakefile +21 -0
- data/SECURITY.md +23 -0
- data/TODO.md +24 -0
- data/examples/flag_and_option_specifications.md +24 -24
- data/examples/show_usage_and_version.md +16 -16
- data/lib/clasp/arguments.rb +3 -3
- data/lib/clasp/clasp.rb +3 -3
- data/lib/clasp/cli.rb +3 -3
- data/lib/clasp/doc_.rb +3 -3
- data/lib/clasp/old_module.rb +3 -3
- data/lib/clasp/specifications.rb +3 -3
- data/lib/clasp/util/exceptions.rb +3 -3
- data/lib/clasp/util/value_parser.rb +3 -3
- data/lib/clasp/version.rb +5 -5
- data/lib/clasp-ruby.rb +3 -3
- data/lib/clasp.rb +3 -3
- metadata +35 -18
data/README.md
CHANGED
|
@@ -1,40 +1,56 @@
|
|
|
1
1
|
# CLASP.Ruby <!-- omit in toc -->
|
|
2
|
+
|
|
2
3
|
Command-Line Argument Sorting and Parsing, for Ruby
|
|
3
4
|
|
|
5
|
+

|
|
6
|
+
[](https://opensource.org/licenses/BSD-3-Clause)
|
|
4
7
|
[](https://badge.fury.io/rb/clasp-ruby)
|
|
8
|
+
[](https://github.com/synesissoftware/CLASP.Ruby/commits/master)
|
|
9
|
+
[](https://github.com/synesissoftware/CLASP.Ruby/actions/workflows/ruby.yml)
|
|
10
|
+
|
|
5
11
|
|
|
6
12
|
## Table of Contents <!-- omit in toc -->
|
|
7
13
|
|
|
8
14
|
- [Introduction](#introduction)
|
|
9
|
-
|
|
15
|
+
- [libCLImate.Ruby](#libclimateruby)
|
|
10
16
|
- [Installation](#installation)
|
|
11
17
|
- [Components](#components)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
- [Command-line parsing](#command-line-parsing)
|
|
19
|
+
- [Declarative specification of the flags and options for a CLI](#declarative-specification-of-the-flags-and-options-for-a-cli)
|
|
20
|
+
- [Utility functions for displaying usage and version information](#utility-functions-for-displaying-usage-and-version-information)
|
|
15
21
|
- [Examples](#examples)
|
|
16
22
|
- [Project Information](#project-information)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- [
|
|
23
|
+
- [Where to get help](#where-to-get-help)
|
|
24
|
+
- [Contribution guidelines](#contribution-guidelines)
|
|
25
|
+
- [Dependencies](#dependencies)
|
|
26
|
+
- [Efferent (fan-out)](#efferent-fan-out)
|
|
27
|
+
- [Runtime Dependencies (aka "Normal Dependencies")](#runtime-dependencies-aka-normal-dependencies)
|
|
28
|
+
- [Development Dependencies](#development-dependencies)
|
|
29
|
+
- [Afferent (fan-in)](#afferent-fan-in)
|
|
30
|
+
- [Runtime dependents](#runtime-dependents)
|
|
31
|
+
- [Development dependents](#development-dependents)
|
|
32
|
+
- [Related projects](#related-projects)
|
|
33
|
+
- [License](#license)
|
|
34
|
+
|
|
21
35
|
|
|
22
36
|
## Introduction
|
|
23
37
|
|
|
24
|
-
**CLASP** stands for **C**ommand-**L**ine **A**rgument **S**orting and **P**arsing. The first **CLASP** library was a C library with a C++ wrapper (see project [**CLASP**](https://github.com/synesissoftware/CLASP/)). There have been several implementations in other languages (as listed in [
|
|
38
|
+
**CLASP** stands for **C**ommand-**L**ine **A**rgument **S**orting and **P**arsing. The first **CLASP** library was a C library with a C++ wrapper (see project [**CLASP**](https://github.com/synesissoftware/CLASP/)). There have been several implementations in other languages (as listed in [Related projects](#related-projects)). **CLASP.Ruby** is the Ruby version.
|
|
25
39
|
|
|
26
40
|
All **CLASP** libraries provide the facilities to **C**ommand **L**ine **I**nterface (**CLI**) programs as described in detail below.
|
|
27
41
|
|
|
42
|
+
|
|
28
43
|
### libCLImate.Ruby
|
|
29
44
|
|
|
30
|
-
The [**libCLImate.Ruby**](https://github.com/synesissoftware/libCLImate.Ruby) library is implemented in terms of **CLASP.Ruby** but provides a higher-level
|
|
45
|
+
The [**libCLImate.Ruby**](https://github.com/synesissoftware/libCLImate.Ruby) library is implemented in terms of **CLASP.Ruby** but provides a higher-level abstraction as well as several utility functions and the facility to fully specify command-line arguments declaratively in the `__END__` section of a source file. More information and examples provided in the [**libCLImate.Ruby**](https://github.com/synesissoftware/libCLImate.Ruby) project.
|
|
46
|
+
|
|
31
47
|
|
|
32
48
|
## Installation
|
|
33
49
|
|
|
34
50
|
Install via **gem** as in:
|
|
35
51
|
|
|
36
52
|
```
|
|
37
|
-
|
|
53
|
+
gem install clasp-ruby
|
|
38
54
|
```
|
|
39
55
|
|
|
40
56
|
or add it to your `Gemfile`.
|
|
@@ -45,8 +61,10 @@ Use via **require**, as in:
|
|
|
45
61
|
require 'clasp'
|
|
46
62
|
```
|
|
47
63
|
|
|
64
|
+
|
|
48
65
|
## Components
|
|
49
66
|
|
|
67
|
+
|
|
50
68
|
### Command-line parsing
|
|
51
69
|
|
|
52
70
|
All **CLASP** libraries discriminate between three types of command-line arguments:
|
|
@@ -97,6 +115,7 @@ UNIX standard arguments confer specific meanings:
|
|
|
97
115
|
* `--version` means that the program should show the version information and terminate;
|
|
98
116
|
* `--` means that all subsequent arguments should be treated as values, regardless of any hyphen-prefixes or embedded `=` signs.
|
|
99
117
|
|
|
118
|
+
|
|
100
119
|
### Declarative specification of the flags and options for a CLI
|
|
101
120
|
|
|
102
121
|
To support such above special processing, CLASP libraries provide facilities
|
|
@@ -139,6 +158,7 @@ puts Args.values[1] # => "outfile"
|
|
|
139
158
|
|
|
140
159
|
```
|
|
141
160
|
|
|
161
|
+
|
|
142
162
|
### Utility functions for displaying usage and version information
|
|
143
163
|
|
|
144
164
|
There are aspects common to all CLI programs, such as responding to `--help` and `--version`. All **CLASP** libraries provide facilities to assist the programmer: **CLASP.Ruby** provides the two module methods CLASP.show_usage() and CLASP.show_version(), as shown in the following code extending the example above:
|
|
@@ -165,7 +185,7 @@ Args.flags.each do |f|
|
|
|
165
185
|
Given the command
|
|
166
186
|
|
|
167
187
|
```
|
|
168
|
-
|
|
188
|
+
./cr-example.rb --help
|
|
169
189
|
```
|
|
170
190
|
|
|
171
191
|
then the program will output the following
|
|
@@ -200,7 +220,7 @@ flags/options:
|
|
|
200
220
|
and given the command
|
|
201
221
|
|
|
202
222
|
```
|
|
203
|
-
|
|
223
|
+
./cr-example.rb --version
|
|
204
224
|
```
|
|
205
225
|
|
|
206
226
|
then the program will output the following
|
|
@@ -209,44 +229,81 @@ then the program will output the following
|
|
|
209
229
|
cr-example.rb 0.1.2
|
|
210
230
|
```
|
|
211
231
|
|
|
232
|
+
|
|
212
233
|
## Examples
|
|
213
234
|
|
|
214
235
|
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).
|
|
215
236
|
|
|
237
|
+
|
|
216
238
|
## Project Information
|
|
217
239
|
|
|
240
|
+
|
|
218
241
|
### Where to get help
|
|
219
242
|
|
|
220
243
|
[GitHub Page](https://github.com/synesissoftware/CLASP.Ruby "GitHub Page")
|
|
221
244
|
|
|
245
|
+
|
|
222
246
|
### Contribution guidelines
|
|
223
247
|
|
|
224
248
|
Defect reports, feature requests, and pull requests are welcome on https://github.com/synesissoftware/CLASP.Ruby.
|
|
225
249
|
|
|
250
|
+
|
|
251
|
+
### Dependencies
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
#### Efferent (fan-out)
|
|
255
|
+
|
|
256
|
+
Libraries upon which **CLASP.Ruby** depends:
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
##### Runtime Dependencies (aka "Normal Dependencies")
|
|
260
|
+
|
|
261
|
+
* \<none>;
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
##### Development Dependencies
|
|
265
|
+
|
|
266
|
+
* [**rake**](https://rubygems.org/gems/rake);
|
|
267
|
+
* [**test-unit**](https://rubygems.org/gems/test-unit);
|
|
268
|
+
* [**xqsr3**](https://github.com/synesissoftware/xqsr3);
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
#### Afferent (fan-in)
|
|
272
|
+
|
|
273
|
+
Projects that depend on **CLASP.Ruby**:
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
##### Runtime dependents
|
|
277
|
+
|
|
278
|
+
* [**libCLImate.Ruby**](https://github.com/synesissoftware/libCLImate.Ruby);
|
|
279
|
+
* [**oss-src-tools**](https://github.com/mwsis/oss-src-tools);
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
##### Development dependents
|
|
283
|
+
|
|
284
|
+
* \<none>;
|
|
285
|
+
|
|
286
|
+
|
|
226
287
|
### Related projects
|
|
227
288
|
|
|
228
289
|
**CLASP.Ruby** is inspired by the [C/C++ CLASP library](https://github.com/synesissoftware/CLASP), which is documented in the articles:
|
|
229
290
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
291
|
+
* _An Introduction to CLASP_, Matthew Wilson, [CVu](http://accu.org/index.php/journals/c77/), January 2012;
|
|
292
|
+
* _[Anatomy of a CLI Program written in C](http://synesis.com.au/publishing/software-anatomies/anatomy-of-a-cli-program-written-in-c.html)_, Matthew Wilson, [CVu](http://accu.org/index.php/journals/c77/), September 2012; and
|
|
293
|
+
* _[Anatomy of a CLI Program written in C++](http://synesis.com.au/publishing/software-anatomies/anatomy-of-a-cli-program-written-in-c++.html)_, Matthew Wilson, [CVu](http://accu.org/index.php/journals/c77/), September 2015;
|
|
233
294
|
|
|
234
295
|
Other CLASP libraries include:
|
|
235
296
|
|
|
236
|
-
* [**CLASP**](https://github.com/synesissoftware/CLASP/)
|
|
237
|
-
* [**CLASP.Go**](https://github.com/synesissoftware/CLASP.Go/)
|
|
238
|
-
* [**CLASP.js**](https://github.com/synesissoftware/CLASP.js/)
|
|
239
|
-
* [**CLASP.NET**](https://github.com/synesissoftware/CLASP.NET/)
|
|
240
|
-
* [**CLASP.Python**](https://github.com/synesissoftware/CLASP.Python/)
|
|
297
|
+
* [**CLASP**](https://github.com/synesissoftware/CLASP/);
|
|
298
|
+
* [**CLASP.Go**](https://github.com/synesissoftware/CLASP.Go/);
|
|
299
|
+
* [**CLASP.js**](https://github.com/synesissoftware/CLASP.js/);
|
|
300
|
+
* [**CLASP.NET**](https://github.com/synesissoftware/CLASP.NET/);
|
|
301
|
+
* [**CLASP.Python**](https://github.com/synesissoftware/CLASP.Python/);
|
|
241
302
|
|
|
242
|
-
Projects in which **CLASP.Ruby** is used include:
|
|
243
|
-
|
|
244
|
-
* [**libCLImate.Ruby**](https://github.com/synesissoftware/libCLImate.Ruby)
|
|
245
303
|
|
|
246
304
|
### License
|
|
247
305
|
|
|
248
|
-
**CLASP.Ruby** is released under the 3-clause BSD license. See LICENSE for details.
|
|
306
|
+
**CLASP.Ruby** is released under the 3-clause BSD license. See [LICENSE](./LICENSE) for details.
|
|
249
307
|
|
|
250
308
|
|
|
251
309
|
<!-- ########################### end of file ########################### -->
|
|
252
|
-
|
data/Rakefile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Rakefile for CLASP.Ruby
|
|
4
|
+
|
|
5
|
+
require 'rake/testtask'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Rake::TestTask.new do |tt|
|
|
9
|
+
|
|
10
|
+
tt.libs << 'lib'
|
|
11
|
+
tt.libs << 'test'
|
|
12
|
+
tt.name = 'test'
|
|
13
|
+
tt.test_files = FileList['test/**/tc_*.rb']
|
|
14
|
+
tt.verbose = true
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
task :default => :test
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# ############################## end of file ############################# #
|
data/SECURITY.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# CLASP.Ruby - Security <!-- omit in toc -->
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Table of Contents <!-- omit in toc -->
|
|
5
|
+
|
|
6
|
+
- [Reporting a vulnerability](#reporting-a-vulnerability)
|
|
7
|
+
- [Supported versions](#supported-versions)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## Reporting a vulnerability
|
|
11
|
+
|
|
12
|
+
Please report security issues privately via GitHub Security Advisories on https://github.com/synesissoftware/CLASP.Ruby/security, or by opening an issue if an advisory cannot be filed. Do not attach exploit proofs of concept against third-party systems.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## Supported versions
|
|
16
|
+
|
|
17
|
+
| Version | Supported |
|
|
18
|
+
| ------- | --------- |
|
|
19
|
+
| 0.23.x | ✅ |
|
|
20
|
+
| < 0.23 | ❌ |
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
<!-- ########################### end of file ########################### -->
|
data/TODO.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# CLASP.Ruby - TODO <!-- omit in toc -->
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Functional improvements
|
|
5
|
+
|
|
6
|
+
* \<none>
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Performance improvements
|
|
10
|
+
|
|
11
|
+
* \<none>
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## Packaging improvements
|
|
15
|
+
|
|
16
|
+
* [x] ~~~rename gemspec so the filename stem matches `spec.name` (`CLASP.gemspec` → **clasp-ruby.gemspec**)~~~;
|
|
17
|
+
* [x] ~~~obtain a **run_all_unit_tests.sh** (from **misc-dev-scripts**) that skips `tput` when `$TERM` is unset or stdout is not a TTY (CI: `tput: No value for $TERM and no -T specified`)~~~;
|
|
18
|
+
* [x] ~~~drop gemspec `required_ruby_version` `< 4` upper bound~~~;
|
|
19
|
+
* [x] ~~~gemspec polish: README tagline as `spec.summary`, include **CHANGES.md** (and sibling docs) in packaged files, exclude **Gemfile.lock** / **.ruby-version**~~~;
|
|
20
|
+
* [x] ~~~stop tracking **Gemfile.lock**; **Gemfile** `lockfile false` when Bundler supports it; CI `bundler-cache: false`~~~;
|
|
21
|
+
* [x] ~~~after the packaging/boilerplate/CI baseline: bump **VERSION** and align **CHANGES**/**NEWS**~~~;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
<!-- ########################### end of file ########################### -->
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# CLASP.Ruby Example - **flag_and_option_specifications**
|
|
1
|
+
# CLASP.Ruby - Example - **flag_and_option_specifications**
|
|
2
2
|
|
|
3
3
|
## Summary
|
|
4
4
|
|
|
@@ -21,10 +21,10 @@ ProgramVersion = [ 0, 0, 1 ]
|
|
|
21
21
|
|
|
22
22
|
InfoLines = [
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
'CLASP.Ruby examples',
|
|
25
|
+
:version,
|
|
26
|
+
"Illustrates use of CLASP.Ruby's use of flags, options, and aliases",
|
|
27
|
+
'',
|
|
28
28
|
]
|
|
29
29
|
|
|
30
30
|
# Specify specifications, parse, and checking standard flags
|
|
@@ -35,24 +35,24 @@ Flag_Chatty = CLASP.Flag('--verbosity=chatty', alias: '-c')
|
|
|
35
35
|
|
|
36
36
|
Specifications = [
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
Flag_Debug,
|
|
39
|
+
Option_Verbosity,
|
|
40
|
+
Flag_Chatty,
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
CLASP::FlagSpecification.Help,
|
|
43
|
+
CLASP::FlagSpecification.Version,
|
|
44
44
|
]
|
|
45
45
|
|
|
46
46
|
args = CLASP::Arguments.new ARGV, Specifications
|
|
47
47
|
|
|
48
48
|
if args.flags.include?(CLASP::FlagSpecification.Help)
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
CLASP.show_usage(Specifications, exit_code: 0, version: ProgramVersion, stream: $stdout, info_lines: InfoLines, default_indicator: '*default*')
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
if args.flags.include?('--version')
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
CLASP.show_version(Specifications, exit_code: 0, version: ProgramVersion, stream: $stdout)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
|
|
@@ -60,12 +60,12 @@ end
|
|
|
60
60
|
|
|
61
61
|
if (opt = args.find_option('--verbosity'))
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
$stdout.puts "verbosity is specified as: #{opt.value}"
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
if args.flags.include?('--debug')
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
$stdout.puts 'Debug mode is specified'
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
|
|
@@ -74,9 +74,9 @@ end
|
|
|
74
74
|
|
|
75
75
|
if (unused = args.find_first_unknown())
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
$stderr.puts "#{args.program_name}: unrecognised flag/option: #{unused}"
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
exit 1
|
|
80
80
|
end
|
|
81
81
|
```
|
|
82
82
|
|
|
@@ -87,13 +87,13 @@ end
|
|
|
87
87
|
If executed with no arguments
|
|
88
88
|
|
|
89
89
|
```
|
|
90
|
-
|
|
90
|
+
ruby examples/flag_and_option_specifications.rb
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
or (in a Unix shell):
|
|
94
94
|
|
|
95
95
|
```
|
|
96
|
-
|
|
96
|
+
./examples/flag_and_option_specifications.rb
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
it gives the output:
|
|
@@ -106,7 +106,7 @@ it gives the output:
|
|
|
106
106
|
If executed with the arguments
|
|
107
107
|
|
|
108
108
|
```
|
|
109
|
-
|
|
109
|
+
ruby examples/flag_and_option_specifications.rb --help
|
|
110
110
|
```
|
|
111
111
|
|
|
112
112
|
it gives the output:
|
|
@@ -146,7 +146,7 @@ flags/options:
|
|
|
146
146
|
If executed with the arguments
|
|
147
147
|
|
|
148
148
|
```
|
|
149
|
-
|
|
149
|
+
ruby examples/flag_and_option_specifications.rb --debug --verbosity=silent
|
|
150
150
|
```
|
|
151
151
|
|
|
152
152
|
it gives the output:
|
|
@@ -161,7 +161,7 @@ Debug mode is specified
|
|
|
161
161
|
If executed with the arguments
|
|
162
162
|
|
|
163
163
|
```
|
|
164
|
-
|
|
164
|
+
ruby examples/flag_and_option_specifications.rb -v silent -d
|
|
165
165
|
```
|
|
166
166
|
|
|
167
167
|
it gives the (same) output:
|
|
@@ -176,7 +176,7 @@ Debug mode is specified
|
|
|
176
176
|
If executed with the arguments
|
|
177
177
|
|
|
178
178
|
```
|
|
179
|
-
|
|
179
|
+
ruby examples/flag_and_option_specifications.rb -c -d
|
|
180
180
|
```
|
|
181
181
|
|
|
182
182
|
it gives the output:
|
|
@@ -191,7 +191,7 @@ Debug mode is specified
|
|
|
191
191
|
If executed with the arguments
|
|
192
192
|
|
|
193
193
|
```
|
|
194
|
-
|
|
194
|
+
ruby examples/flag_and_option_specifications.rb -dc
|
|
195
195
|
```
|
|
196
196
|
|
|
197
197
|
it gives the (same) output:
|
|
@@ -206,7 +206,7 @@ Debug mode is specified
|
|
|
206
206
|
If executed with the arguments
|
|
207
207
|
|
|
208
208
|
```
|
|
209
|
-
|
|
209
|
+
ruby examples/flag_and_option_specifications.rb -d --verbosity=
|
|
210
210
|
```
|
|
211
211
|
|
|
212
212
|
it gives the output:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# CLASP.Ruby Example - **show_usage_and_version**
|
|
1
|
+
# CLASP.Ruby - Example - **show_usage_and_version**
|
|
2
2
|
|
|
3
3
|
## Summary
|
|
4
4
|
|
|
@@ -21,30 +21,30 @@ ProgramVersion = [ 0, 0, 1 ]
|
|
|
21
21
|
|
|
22
22
|
InfoLines = [
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
'CLASP.Ruby examples',
|
|
25
|
+
:version,
|
|
26
|
+
"Illustrates use of CLASP.Ruby's CLASP.show_usage() and CLASP.show_version() methods",
|
|
27
|
+
'',
|
|
28
28
|
]
|
|
29
29
|
|
|
30
30
|
# Specify specifications, parse, and checking standard flags
|
|
31
31
|
|
|
32
32
|
Specifications = [
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
CLASP::FlagSpecification.Help,
|
|
35
|
+
CLASP::FlagSpecification.Version,
|
|
36
36
|
]
|
|
37
37
|
|
|
38
38
|
args = CLASP::Arguments.new ARGV, Specifications
|
|
39
39
|
|
|
40
40
|
if args.flags.include?('--help')
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
CLASP.show_usage(Specifications, exit_code: 0, version: ProgramVersion, stream: $stdout, info_lines: InfoLines)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
if args.flags.include?('--version')
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
CLASP.show_version(Specifications, exit_code: 0, version: ProgramVersion, stream: $stdout)
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
|
|
@@ -52,9 +52,9 @@ end
|
|
|
52
52
|
|
|
53
53
|
if (unused = args.find_first_unknown())
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
$stderr.puts "#{args.program_name}: unrecognised flag/option: #{unused}"
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
sys.exit(1)
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
|
|
@@ -68,13 +68,13 @@ $stdout.puts 'no flags specified'
|
|
|
68
68
|
If executed with no arguments
|
|
69
69
|
|
|
70
70
|
```
|
|
71
|
-
|
|
71
|
+
ruby examples/show_usage_and_version.rb
|
|
72
72
|
```
|
|
73
73
|
|
|
74
74
|
or (in a Unix shell):
|
|
75
75
|
|
|
76
76
|
```
|
|
77
|
-
|
|
77
|
+
./examples/show_usage_and_version.rb
|
|
78
78
|
```
|
|
79
79
|
|
|
80
80
|
it gives the output:
|
|
@@ -88,7 +88,7 @@ no flags specified
|
|
|
88
88
|
If executed with the arguments
|
|
89
89
|
|
|
90
90
|
```
|
|
91
|
-
|
|
91
|
+
ruby examples/show_usage_and_version.rb --help
|
|
92
92
|
```
|
|
93
93
|
|
|
94
94
|
it gives the output:
|
|
@@ -114,7 +114,7 @@ flags/options:
|
|
|
114
114
|
If executed with the arguments
|
|
115
115
|
|
|
116
116
|
```
|
|
117
|
-
|
|
117
|
+
ruby examples/show_usage_and_version.rb --version
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
it gives the output:
|
|
@@ -128,7 +128,7 @@ show_usage_and_version.rb 0.0.1
|
|
|
128
128
|
If executed with the arguments
|
|
129
129
|
|
|
130
130
|
```
|
|
131
|
-
|
|
131
|
+
ruby examples/show_usage_and_version.rb --unknown=value
|
|
132
132
|
```
|
|
133
133
|
|
|
134
134
|
it gives the output (on the standard error stream):
|
data/lib/clasp/arguments.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
# ######################################################################## #
|
|
3
3
|
# File: clasp/arguments.rb
|
|
4
4
|
#
|
|
5
5
|
# Purpose: Definition of the Arguments class, the main class in CLASP.Ruby
|
|
6
6
|
#
|
|
7
7
|
# Created: 14th February 2014
|
|
8
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
9
9
|
#
|
|
10
|
-
# Home:
|
|
10
|
+
# Home: https://github.com/synesissoftware/CLASP.Ruby
|
|
11
11
|
#
|
|
12
12
|
# Author: Matthew Wilson
|
|
13
13
|
#
|
data/lib/clasp/clasp.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
# ######################################################################## #
|
|
3
3
|
# File: clasp/clasp.rb
|
|
4
4
|
#
|
|
5
5
|
# Purpose: Common 'require file' for CLASP.Ruby library
|
|
6
6
|
#
|
|
7
7
|
# Created: 14th February 2014
|
|
8
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
9
9
|
#
|
|
10
|
-
# Home:
|
|
10
|
+
# Home: https://github.com/synesissoftware/CLASP.Ruby
|
|
11
11
|
#
|
|
12
12
|
# Author: Matthew Wilson
|
|
13
13
|
#
|
data/lib/clasp/cli.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
# ######################################################################## #
|
|
3
3
|
# File: clasp/cli.rb
|
|
4
4
|
#
|
|
5
5
|
# Purpose: Command-line interface
|
|
6
6
|
#
|
|
7
7
|
# Created: 27th July 2015
|
|
8
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
9
9
|
#
|
|
10
|
-
# Home:
|
|
10
|
+
# Home: https://github.com/synesissoftware/CLASP.Ruby
|
|
11
11
|
#
|
|
12
12
|
# Author: Matthew Wilson
|
|
13
13
|
#
|
data/lib/clasp/doc_.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
# ######################################################################## #
|
|
3
3
|
# File: lib/xqsr3/doc_.rb
|
|
4
4
|
#
|
|
5
5
|
# Purpose: Documentation of the CLASP.Ruby modules
|
|
6
6
|
#
|
|
7
7
|
# Created: 11th June 2016
|
|
8
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
9
9
|
#
|
|
10
|
-
# Home:
|
|
10
|
+
# Home: https://github.com/synesissoftware/CLASP.Ruby
|
|
11
11
|
#
|
|
12
12
|
# Author: Matthew Wilson
|
|
13
13
|
#
|
data/lib/clasp/old_module.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
# ######################################################################## #
|
|
3
3
|
# File: clasp/old_module.rb
|
|
4
4
|
#
|
|
5
5
|
# Purpose: Introduces old module Clasp (which clashes with an existing gem)
|
|
6
6
|
#
|
|
7
7
|
# Created: 10th June 2016
|
|
8
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
9
9
|
#
|
|
10
|
-
# Home:
|
|
10
|
+
# Home: https://github.com/synesissoftware/CLASP.Ruby
|
|
11
11
|
#
|
|
12
12
|
# Author: Matthew Wilson
|
|
13
13
|
#
|
data/lib/clasp/specifications.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
# ######################################################################## #
|
|
3
3
|
# File: clasp/specifications.rb
|
|
4
4
|
#
|
|
5
5
|
# Purpose: Argument specification classes
|
|
6
6
|
#
|
|
7
7
|
# Created: 25th October 2014
|
|
8
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
9
9
|
#
|
|
10
|
-
# Home:
|
|
10
|
+
# Home: https://github.com/synesissoftware/CLASP.Ruby
|
|
11
11
|
#
|
|
12
12
|
# Author: Matthew Wilson
|
|
13
13
|
#
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
# ######################################################################## #
|
|
3
3
|
# File: clasp/util/exceptions.rb
|
|
4
4
|
#
|
|
5
5
|
# Purpose: Exception classes
|
|
6
6
|
#
|
|
7
7
|
# Created: 20th April 2019
|
|
8
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
9
9
|
#
|
|
10
|
-
# Home:
|
|
10
|
+
# Home: https://github.com/synesissoftware/CLASP.Ruby
|
|
11
11
|
#
|
|
12
12
|
# Author: Matthew Wilson
|
|
13
13
|
#
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
# ######################################################################## #
|
|
3
3
|
# File: clasp/util/value_parser.rb
|
|
4
4
|
#
|
|
5
5
|
# Purpose: Utility component for typed values
|
|
6
6
|
#
|
|
7
7
|
# Created: 20th April 2019
|
|
8
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
9
9
|
#
|
|
10
|
-
# Home:
|
|
10
|
+
# Home: https://github.com/synesissoftware/CLASP.Ruby
|
|
11
11
|
#
|
|
12
12
|
# Author: Matthew Wilson
|
|
13
13
|
#
|