opt_parse_builder 0.1.0 → 0.2.0
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/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +8 -1
- data/Gemfile.lock +15 -15
- data/README.md +43 -4
- data/lib/opt_parse_builder/argument_builder.rb +2 -2
- data/lib/opt_parse_builder/version.rb +1 -1
- data/rake/rdoc.rake +16 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39695b1c1e778b1f947bc02eae0b0942405f686e1b2295db180b47056c6bf8a3
|
4
|
+
data.tar.gz: 1daba7a89dc175c9c5b087ff9a03fb50e7ede303f0bdf7289b23e994cd6161af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0876b80178845db9da8786262ffd10a0c00a3ca63f980efb99c9d1aff03422afce8dc10c2ba9fc9dba67ca18c3c32466b0c65860fb89280b39560811ed654e33'
|
7
|
+
data.tar.gz: 705942c096e316892af5f7b5a70083da538556d0d2559b67a091e0fe3b7e1b4d8aa5966e8550327e63e90213e205bf076576e779fd7939f3b225fd4715a54a61
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-
|
1
|
+
ruby-3.4.4
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
opt_parse_builder (0.
|
4
|
+
opt_parse_builder (0.2.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
diff-lcs (1.
|
10
|
-
rake (13.0
|
11
|
-
rspec (3.
|
12
|
-
rspec-core (~> 3.
|
13
|
-
rspec-expectations (~> 3.
|
14
|
-
rspec-mocks (~> 3.
|
15
|
-
rspec-core (3.
|
16
|
-
rspec-support (~> 3.
|
17
|
-
rspec-expectations (3.
|
9
|
+
diff-lcs (1.6.2)
|
10
|
+
rake (13.3.0)
|
11
|
+
rspec (3.13.1)
|
12
|
+
rspec-core (~> 3.13.0)
|
13
|
+
rspec-expectations (~> 3.13.0)
|
14
|
+
rspec-mocks (~> 3.13.0)
|
15
|
+
rspec-core (3.13.5)
|
16
|
+
rspec-support (~> 3.13.0)
|
17
|
+
rspec-expectations (3.13.5)
|
18
18
|
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
-
rspec-support (~> 3.
|
20
|
-
rspec-mocks (3.
|
19
|
+
rspec-support (~> 3.13.0)
|
20
|
+
rspec-mocks (3.13.5)
|
21
21
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
-
rspec-support (~> 3.
|
23
|
-
rspec-support (3.
|
22
|
+
rspec-support (~> 3.13.0)
|
23
|
+
rspec-support (3.13.4)
|
24
24
|
|
25
25
|
PLATFORMS
|
26
26
|
ruby
|
@@ -32,4 +32,4 @@ DEPENDENCIES
|
|
32
32
|
rspec (~> 3.10)
|
33
33
|
|
34
34
|
BUNDLED WITH
|
35
|
-
2.
|
35
|
+
2.6.9
|
data/README.md
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
A Ruby Gem for processing CLI arguments using optparse. Adds to
|
4
4
|
optparse a compact builder-style DSL, operand (positional argument)
|
5
|
-
parsing, and
|
6
|
-
|
5
|
+
parsing, and easy sharing of argument definitions within a suite of
|
6
|
+
commands.
|
7
7
|
|
8
8
|
Features:
|
9
9
|
|
@@ -37,7 +37,7 @@ Features:
|
|
37
37
|
* Fully documented - Includes full code documentation and examples.
|
38
38
|
|
39
39
|
* Stable API - Uses [semantic
|
40
|
-
versioning](
|
40
|
+
versioning](#label-Versioning). Promises not to
|
41
41
|
break your program without incrementing the major version number.
|
42
42
|
|
43
43
|
* Programmed simply - Easy to understand and modify.
|
@@ -125,9 +125,15 @@ parser = OptParseBuilder.build_parser do |args|
|
|
125
125
|
end
|
126
126
|
```
|
127
127
|
|
128
|
+
### Use in program suites
|
129
|
+
|
128
130
|
This is especially useful where a suite of programs share some
|
129
131
|
arguments in common. Instead of defining common arguments over and
|
130
|
-
over, you can define them once and then reuse them in each program
|
132
|
+
over, you can define them once and then reuse them in each program.
|
133
|
+
|
134
|
+
*Design note* This is the reason this library was created. Other
|
135
|
+
solutions I found for sharing common CLI options required the programs
|
136
|
+
to be part of a framework; I wanted something that worked by itself.
|
131
137
|
|
132
138
|
```ruby
|
133
139
|
# common_arguments.rb
|
@@ -172,6 +178,8 @@ ARG_PARSER = OptParseBuilder.build_parser do |args|
|
|
172
178
|
end
|
173
179
|
```
|
174
180
|
|
181
|
+
### Switching between required and optional
|
182
|
+
|
175
183
|
When adding a pre-built operand to a parser, you can change change
|
176
184
|
it from required to optional:
|
177
185
|
|
@@ -323,6 +331,9 @@ A value option parsed by OptParse:
|
|
323
331
|
arg.on "Number of iterations (default _DEFAULT_)"
|
324
332
|
end
|
325
333
|
|
334
|
+
The string "_DEFAULT_" is replaced with the default value (in this
|
335
|
+
example, "100").
|
336
|
+
|
326
337
|
Applicable builder methods:
|
327
338
|
|
328
339
|
* key
|
@@ -393,6 +404,34 @@ Applicable builder methods:
|
|
393
404
|
* banner (optional)
|
394
405
|
* separator (optional)
|
395
406
|
|
407
|
+
# Error handling and abnormal termination
|
408
|
+
|
409
|
+
The invokation of help via "-h" or "--help" prints out the program
|
410
|
+
help and ends the program with exitcode 0.
|
411
|
+
|
412
|
+
Errors during building result in an uncaught BuildError.
|
413
|
+
|
414
|
+
OptParse errors are handled by Kernel#abort, which prints the error to
|
415
|
+
$stderr and ends the program with exit code 1.
|
416
|
+
|
417
|
+
# Ruby versions supported
|
418
|
+
|
419
|
+
* 2.5
|
420
|
+
* 2.6
|
421
|
+
* 2.7
|
422
|
+
* 3.0
|
423
|
+
|
424
|
+
# Versioning
|
425
|
+
|
426
|
+
This library uses [semantic
|
427
|
+
versioning](https://semver.org/spec/v2.0.0.html). As long as you
|
428
|
+
stick to the public API, upgrades to this library will not break your
|
429
|
+
program without incrementing the major version number.
|
430
|
+
|
431
|
+
The public API is that document using RDOC comments.
|
432
|
+
If a class or method is documented with `# :nodoc:`, then it's not
|
433
|
+
part of the public API.
|
434
|
+
|
396
435
|
# Development
|
397
436
|
|
398
437
|
After checking out the repo, run `bundle` to install dependencies.
|
@@ -41,7 +41,7 @@ module OptParseBuilder
|
|
41
41
|
#
|
42
42
|
# arg = OptParseBuilder.build_argument do |arg|
|
43
43
|
# arg.key :quiet
|
44
|
-
# arg.on "-q", "Be very
|
44
|
+
# arg.on "-q", "Be very very quiet", "We're hunting rabbit!"
|
45
45
|
# end
|
46
46
|
#
|
47
47
|
# You may split up a long argument list by calling this method
|
@@ -49,7 +49,7 @@ module OptParseBuilder
|
|
49
49
|
#
|
50
50
|
# arg = OptParseBuilder.build_argument do |arg|
|
51
51
|
# arg.key :quiet
|
52
|
-
# arg.on "-q", "Be very
|
52
|
+
# arg.on "-q", "Be very very quiet",
|
53
53
|
# arg.on "We're hunting rabbit!"
|
54
54
|
# end
|
55
55
|
#
|
data/rake/rdoc.rake
CHANGED
@@ -1,7 +1,22 @@
|
|
1
1
|
require 'rdoc/task'
|
2
2
|
|
3
|
+
RDOC_PATHS = [
|
4
|
+
"README.md",
|
5
|
+
"lib",
|
6
|
+
]
|
7
|
+
|
3
8
|
RDoc::Task.new do |rdoc|
|
4
9
|
rdoc.main = "README.md"
|
5
10
|
rdoc.markup = :markdown
|
6
|
-
rdoc.rdoc_files.include(
|
11
|
+
rdoc.rdoc_files.include(RDOC_PATHS)
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Print RDOC coverage report"
|
15
|
+
task "rdoc:coverage" do
|
16
|
+
command = [
|
17
|
+
"rdoc",
|
18
|
+
"--coverage-report",
|
19
|
+
*RDOC_PATHS,
|
20
|
+
]
|
21
|
+
system(*command)
|
7
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opt_parse_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wayne Conrad
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
@@ -104,7 +103,6 @@ homepage: https://github.com/wconrad/opt_parse_builder
|
|
104
103
|
licenses:
|
105
104
|
- MIT
|
106
105
|
metadata: {}
|
107
|
-
post_install_message:
|
108
106
|
rdoc_options: []
|
109
107
|
require_paths:
|
110
108
|
- lib
|
@@ -119,8 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
117
|
- !ruby/object:Gem::Version
|
120
118
|
version: '0'
|
121
119
|
requirements: []
|
122
|
-
rubygems_version: 3.
|
123
|
-
signing_key:
|
120
|
+
rubygems_version: 3.6.7
|
124
121
|
specification_version: 4
|
125
122
|
summary: Builder DSL for optparse, with more
|
126
123
|
test_files: []
|