opt_parse_builder 0.1.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28f64f160f1a3940a3884f5f56ecba366ba6078be1c3032b625f0cded4124259
4
- data.tar.gz: d81a3b030a5e8b60b97577148c5e91810c7a9125e0f08c6ad01e68f76a0d58ff
3
+ metadata.gz: ae59f7036ba75769d0965d67ec2b8d79c9d1965d3867898ee40b1a6e39d63395
4
+ data.tar.gz: d92e59065fc880fb4b0182f4a9f3d608bc88d69333a37267f7edaae36efd41b2
5
5
  SHA512:
6
- metadata.gz: d48ea90e1d556a24a649124d33ca1329c743384066da239472c240aec47b9b113785a9e321365b2fac1b4f90ef08e9a370664693c330b326e0a510f666d650d4
7
- data.tar.gz: 68ccc121fe7a7703f16d2bac471a69abcf0af241a7c85aef53554de9c1609bb464e2a8a5eba3ad1fd39a382d91d5f433cab554e55be6a072347ed96d24fb2f27
6
+ metadata.gz: 688195cd6207f2a4dbb5aebb66851efe094a17a1e3c55d87cd38f62ffe72cc15acd665c1ad64e203abe806f8a5cb767dd4ff46123f4c521f003b70e570a883b8
7
+ data.tar.gz: 97a98d23c58dbbeda7136b5399455bde1d00840c2748409f8ae85dce667d06f4b114ac7e00ea110bd5bdd8a58758af11ba0d34b975960acea67db21cc80aa325
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
1
  html
2
2
  *.gem
3
+ temp
4
+ .claude/
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.7.2
1
+ ruby-3.4.7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # -*- mode: fundamental -*-
2
-
2
+
3
3
  # Development
4
4
 
5
+ # 1.0.0 - 2025-11-28
6
+
7
+ * Declare API stability by bumping version to 1.0.0
8
+ * Update gems
9
+ * Update Ruby to 3.4.7
10
+
11
+ # 0.2.0 - 2025-07-06
12
+
13
+ * Update gems
14
+ * Update Ruby to 3.4.4
15
+
16
+ # 0.1.0 - 2020-11-28
17
+
5
18
  * Initial release
data/Gemfile.lock CHANGED
@@ -1,26 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- opt_parse_builder (0.1.0)
4
+ opt_parse_builder (1.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- diff-lcs (1.4.4)
10
- rake (13.0.1)
11
- rspec (3.10.0)
12
- rspec-core (~> 3.10.0)
13
- rspec-expectations (~> 3.10.0)
14
- rspec-mocks (~> 3.10.0)
15
- rspec-core (3.10.0)
16
- rspec-support (~> 3.10.0)
17
- rspec-expectations (3.10.0)
9
+ diff-lcs (1.6.2)
10
+ rake (13.3.1)
11
+ rspec (3.13.2)
12
+ rspec-core (~> 3.13.0)
13
+ rspec-expectations (~> 3.13.0)
14
+ rspec-mocks (~> 3.13.0)
15
+ rspec-core (3.13.6)
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.10.0)
20
- rspec-mocks (3.10.0)
19
+ rspec-support (~> 3.13.0)
20
+ rspec-mocks (3.13.7)
21
21
  diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.10.0)
23
- rspec-support (3.10.0)
22
+ rspec-support (~> 3.13.0)
23
+ rspec-support (3.13.6)
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.1.4
35
+ 2.7.2
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 composability for sharing argument definitions within a
6
- suite of commands.
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](ttps://semver.org/spec/v2.0.0.html). Promises not to
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.
data/doc/publishing.md ADDED
@@ -0,0 +1,42 @@
1
+ Publishing a New Release
2
+
3
+ # Checklist
4
+
5
+ * Run tests: `rake`
6
+ * Update `lib/opt_parse_builder/version.rb`
7
+ * Update `CHANGELOG.md` with version and date
8
+ * Commit: `git commit -am "Bump version to X.X.X"`
9
+ * Release: `rake release`
10
+ * Verify at https://rubygems.org/gems/opt_parse_builder
11
+
12
+ # Notes
13
+
14
+ Semantic Versioning: MAJOR.MINOR.PATCH (breaking.feature.bugfix)
15
+
16
+ What `rake release` does:
17
+
18
+ * Builds the gem
19
+ * Creates git tag vX.X.X
20
+ * Pushes tag to GitHub
21
+ * Publishes gem to rubygems.org
22
+
23
+ Dry run: `gem_push=no rake release` (tags but doesn't publish)
24
+
25
+ # Troubleshooting
26
+
27
+ No RubyGems credentials: `gem signin`
28
+
29
+ Release failed mid-way:
30
+
31
+ ```bash
32
+ git tag -d vX.X.X # Delete local tag
33
+ git push origin :vX.X.X # Delete remote tag
34
+ rake release # Try again
35
+ ```
36
+
37
+ Manual publish (if rake release fails):
38
+
39
+ ```bash
40
+ gem build opt_parse_builder.gemspec
41
+ gem push opt_parse_builder-X.X.X.gem
42
+ ```
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "opt_parse_builder"
3
+ require_relative "lib/setup_example"
4
4
 
5
5
  ARG_PARSER = OptParseBuilder.build_parser do |args|
6
6
  args.banner "A simple example"
@@ -0,0 +1,8 @@
1
+ require "bundler/setup"
2
+
3
+ lib_dir = File.join(__dir__, "../../lib")
4
+ if File.directory?(lib_dir)
5
+ $:.prepend lib_dir
6
+ end
7
+
8
+ require "opt_parse_builder"
@@ -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 veru quiet", "We're hunting rabbit!"
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 veru quiet",
52
+ # arg.on "-q", "Be very very quiet",
53
53
  # arg.on "We're hunting rabbit!"
54
54
  # end
55
55
  #
@@ -1,6 +1,6 @@
1
1
  module OptParseBuilder
2
2
 
3
3
  # Library version. Follows Semantic Versioning 2.0
4
- VERSION = "0.1.0"
4
+ VERSION = "1.0.0"
5
5
 
6
6
  end
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("README.md", "lib/**/*.rb")
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.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wayne Conrad
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2020-11-28 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bundler
@@ -72,7 +71,9 @@ files:
72
71
  - LICENSE
73
72
  - README.md
74
73
  - Rakefile
74
+ - doc/publishing.md
75
75
  - examples/hello_world.rb
76
+ - examples/lib/setup_example.rb
76
77
  - lib/opt_parse_builder.rb
77
78
  - lib/opt_parse_builder/argument.rb
78
79
  - lib/opt_parse_builder/argument_builder.rb
@@ -104,7 +105,6 @@ homepage: https://github.com/wconrad/opt_parse_builder
104
105
  licenses:
105
106
  - MIT
106
107
  metadata: {}
107
- post_install_message:
108
108
  rdoc_options: []
109
109
  require_paths:
110
110
  - lib
@@ -119,8 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
121
  requirements: []
122
- rubygems_version: 3.1.4
123
- signing_key:
122
+ rubygems_version: 3.6.9
124
123
  specification_version: 4
125
124
  summary: Builder DSL for optparse, with more
126
125
  test_files: []