benry-cmdopt 2.0.0 → 2.0.2
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/CHANGES.md +13 -0
- data/MIT-LICENSE +1 -1
- data/README.md +15 -17
- data/benry-cmdopt.gemspec +4 -5
- data/doc/benry-cmdopt.html +152 -154
- data/doc/css/style.css +8 -0
- data/lib/benry/cmdopt.rb +3 -3
- data/test/cmdopt_test.rb +17 -0
- metadata +2 -7
- data/Rakefile.rb +0 -11
- data/task/common-task.rb +0 -138
- data/task/package-task.rb +0 -72
- data/task/readme-task.rb +0 -125
- data/task/test-task.rb +0 -81
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c4c465878a37b15c65090a251e576059ac389d2a3457379980e8bb353e43a97
|
4
|
+
data.tar.gz: e0607fa34db598eb81014b7ed63bebe82985ad20a9a311e7be6b0c6c52f01a88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01cc7b1487d89b9777478064f068c31b847038da6fda2841b9b59c0ee55fc9d62a4d3dac7eae5964c9b25fd0da5e52459c27cbb8eac0412293c0b4de8fb910d9
|
7
|
+
data.tar.gz: 934952f9cc686d6014c69034b7aa5810341266b627f5f22719da543baf9f38267cab4214a0aeae8315bb601bc72f96597d976896977c1151fff50c37fe8dce59
|
data/CHANGES.md
CHANGED
@@ -2,6 +2,19 @@ CHANGES
|
|
2
2
|
=======
|
3
3
|
|
4
4
|
|
5
|
+
Release 2.0.2 (2023-10-12)
|
6
|
+
--------------------------
|
7
|
+
|
8
|
+
* [change] remove unnecessary files from gem.
|
9
|
+
* [bugfix] fix to add missing test cases.
|
10
|
+
|
11
|
+
|
12
|
+
Release 2.0.1 (2023-10-11)
|
13
|
+
--------------------------
|
14
|
+
|
15
|
+
* [bugfix] fix documents.
|
16
|
+
|
17
|
+
|
5
18
|
Release 2.0.0 (2023-10-10)
|
6
19
|
--------------------------
|
7
20
|
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# Benry-CmdOpt
|
2
2
|
|
3
|
-
($Release: 2.0.
|
3
|
+
($Release: 2.0.2 $)
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
##
|
7
|
+
## What's This?
|
8
8
|
|
9
9
|
Benry-CmdOpt is a command option parser library, like `optparse.rb`
|
10
10
|
(Ruby standard library).
|
@@ -20,11 +20,11 @@ Benry-CmdOpt requires Ruby >= 2.3.
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
|
23
|
+
### Table of Contents
|
24
24
|
|
25
25
|
<!-- TOC -->
|
26
26
|
|
27
|
-
* [
|
27
|
+
* [What's This?](#whats-this)
|
28
28
|
* [Why not `optparse.rb`?](#why-not-optparserb)
|
29
29
|
* [Install](#install)
|
30
30
|
* [Usage](#usage)
|
@@ -236,8 +236,7 @@ opts = {}
|
|
236
236
|
begin
|
237
237
|
parser.parse!(ARGV, into: opts)
|
238
238
|
rescue OptionParser::ParseError => err # specify error class
|
239
|
-
|
240
|
-
exit 1
|
239
|
+
abort "ERROR: #{err.message}"
|
241
240
|
end
|
242
241
|
|
243
242
|
### benry/cmdopt.rb
|
@@ -245,21 +244,22 @@ require 'benry/cmdopt'
|
|
245
244
|
cmdopt = Benry::CmdOpt.new
|
246
245
|
cmdopt.add(:file, '-f, --file=<FILE>', "filename")
|
247
246
|
opts = cmdopt.parse(ARGV) do |err| # error handling wihtout error class name
|
248
|
-
|
249
|
-
exit 1
|
247
|
+
abort "ERROR: #{err.message}"
|
250
248
|
end
|
251
249
|
```
|
252
250
|
|
253
|
-
*
|
254
|
-
|
255
|
-
|
251
|
+
* The source code of "optparse.rb" is quite large and complex for a command
|
252
|
+
option parser library. The reason is that one large `OptParse` class
|
253
|
+
does everything related to parsing command options. Bad class design.
|
254
|
+
Therefore it is hard to customize or extend `OptionParser` class.
|
256
255
|
|
257
256
|
In contract, `benry/cmdopt.rb` consists of several classes
|
258
257
|
(schema class, parser class, and facade class).
|
259
258
|
Therefore it is easy to understand and extend these classes.
|
260
259
|
|
261
|
-
|
262
|
-
|
260
|
+
In fact, file `optparse.rb` and `optparse/*.rb` (in Ruby 3.2)
|
261
|
+
contains total 1298 lines (except comments and blanks), while
|
262
|
+
`benry/cmdopt.rb` (v2.0.0) contains only 429 lines (except both, too).
|
263
263
|
|
264
264
|
|
265
265
|
|
@@ -286,8 +286,7 @@ cmdopt.add(:version, ' --version', "print version")
|
|
286
286
|
|
287
287
|
## parse with error handling
|
288
288
|
options = cmdopt.parse(ARGV) do |err|
|
289
|
-
|
290
|
-
exit(1)
|
289
|
+
abort "ERROR: #{err.message}"
|
291
290
|
end
|
292
291
|
p options # ex: {:help => true, :version => true}
|
293
292
|
p ARGV # options are removed from ARGV
|
@@ -642,8 +641,7 @@ schema.add(:indent, '-i, --indent[=<WIDTH>]', "enable indent", type: Integer)
|
|
642
641
|
parser = Benry::CmdOpt::Parser.new(schema)
|
643
642
|
argv = ['-hi2', '--file=blabla.txt', 'aaa', 'bbb']
|
644
643
|
opts = parser.parse(argv) do |err|
|
645
|
-
|
646
|
-
exit 1
|
644
|
+
abort "ERROR: #{err.message}"
|
647
645
|
end
|
648
646
|
p opts #=> {:help=>true, :indent=>2, :file=>"blabla.txt"}
|
649
647
|
p argv #=> ["aaa", "bbb"]
|
data/benry-cmdopt.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "benry-cmdopt"
|
5
|
-
spec.version = "$Release: 2.0.
|
5
|
+
spec.version = "$Release: 2.0.2 $".split()[1]
|
6
6
|
spec.author = "kwatch"
|
7
7
|
spec.email = "kwatch@gmail.com"
|
8
8
|
spec.platform = Gem::Platform::RUBY
|
@@ -16,10 +16,9 @@ END
|
|
16
16
|
spec.license = "MIT"
|
17
17
|
spec.files = Dir[
|
18
18
|
"README.md", "MIT-LICENSE", "CHANGES.md",
|
19
|
-
"
|
20
|
-
"lib/**/*.rb", "test/**/*.rb", "
|
21
|
-
|
22
|
-
"doc/*.html", "doc/css/*",
|
19
|
+
"#{spec.name}.gemspec",
|
20
|
+
"lib/**/*.rb", "test/**/*.rb", #"bin/*", "examples/**/*",
|
21
|
+
"doc/*.html", "doc/css/*.css",
|
23
22
|
]
|
24
23
|
#spec.executables = []
|
25
24
|
spec.bindir = "bin"
|