shellopts 0.9.7 → 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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -10
  3. data/TODO +11 -1
  4. data/lib/shellopts/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a081efe12e3a4e2f4b38eab4d2f6776c5dc3c748fb06178a4b42dbbba4e9612
4
- data.tar.gz: 27a8d76c4de24c440bd330aa84d2e17014456c927af3c4a12807573df798c01a
3
+ metadata.gz: 4cc3c3ef5b7b13876949b290b9d247c41778eaa38ea01432d5abac47b663478a
4
+ data.tar.gz: bc2c44f163f81d8b51545679e8f8280ac889fbb1f96a7898e5a65fa63d337d4a
5
5
  SHA512:
6
- metadata.gz: 4f21b1f020dd04219272d5772cf0483b88c108af9991450e2532fcdab5322635a80a1cbac512c284358d10f271c03b4adef65ffb379d3df8a1d6635b9ca9f518
7
- data.tar.gz: e88c6c0abcb49a7ba6568aa66c62267a63b92cfb9969387522a52b045fc34d4121cddb4b8c11ffe68d8ed3f13f925391e393e5b4ac292732696de019f7ed4217
6
+ metadata.gz: d3c501335a899e4b14280cbb14b7f9e8a0d9ef28715760394d8f13ea837d0a5d3d9b91b9d07dcb42a747753e97a10c157ae5c5b20b95804b1746e0ebad7d88c9
7
+ data.tar.gz: 387c888158bbbebe127c6efde55c7bbb14436b7dcb8227cac38e2c9dac85e9a3d956c062e04b86101e28fa0bde4977fefadad4d1a643dd48d9218e5c04558ad2
data/README.md CHANGED
@@ -7,11 +7,10 @@ line
7
7
 
8
8
  ## Usage
9
9
 
10
- Program that accepts the options -a or --all, --count, --file, and -v or
11
- --verbose. The usage definition expects `--count` to have an optional integer
12
- argument, `--file` to have a mandatory argument, and allows `-v` and
13
- `--verbose` to be repeated:
14
-
10
+ The following program accepts the options -a or --all, --count, --file, and -v
11
+ or --verbose. It expects `--count` to have an optional integer argument,
12
+ `--file` to have a mandatory argument, and allows `-v` and `--verbose` to be
13
+ repeated:
15
14
 
16
15
  ```ruby
17
16
 
@@ -74,7 +73,7 @@ line at a time and to inspect the grammar and AST
74
73
 
75
74
  ```ruby
76
75
  shellopts = ShellOpts.process(USAGE, ARGV) # Returns a ShellOpts::ShellOpts object
77
- shellopts.each { |opt, val| ... } # Access options
76
+ shellopts.each { |opt, arg| ... } # Access options
78
77
  args = shellopts.args # Access remaining arguments
79
78
  shellopts.error "Something went wrong" # Emit an error message and exit
80
79
  ```
@@ -196,11 +195,11 @@ sub-commands) to the command:
196
195
  ```ruby
197
196
  USAGE = "a cmd! b c"
198
197
 
199
- args = ShellOpts.process(USAGE, ARGV) { |opt,val|
198
+ args = ShellOpts.process(USAGE, ARGV) { |opt, arg|
200
199
  case opt
201
200
  when '-a'; # Handle -a
202
201
  when 'cmd'
203
- opt.each { |opt, val|
202
+ arg.each { |opt, arg|
204
203
  case opt
205
204
  when '-b'; # Handle -b
206
205
  when '-c'; # Handle -c
@@ -320,12 +319,12 @@ preserve_root = true
320
319
  verbose = false
321
320
 
322
321
  # Process command line
323
- args = ShellOpts.process(USAGE, ARGV) { |opt, val|
322
+ args = ShellOpts.process(USAGE, ARGV) { |opt, arg|
324
323
  case opt
325
324
  when '-f', '--force'; force = true
326
325
  when '-i'; prompt = true
327
326
  when '-I'; prompt_once = true
328
- when '--interactive'; interactive = true; interactive_when = val
327
+ when '--interactive'; interactive = true; interactive_when = arg
329
328
  when '-r', '-R', '--recursive'; recursive = true
330
329
  when '-d', '--dir'; remove_empty_dirs = true
331
330
  when '--one-file-system'; one_file_system = true
data/TODO CHANGED
@@ -1,5 +1,15 @@
1
1
 
2
2
  TODO
3
+ o Also allow assignment to usage string for ShellOpts::ShellOpts objects
4
+ o Create a ShellOpts.args method? It would be useful when processing commands:
5
+ case opt
6
+ when "command"
7
+ call_command_method(ShellOpts.args[1], ShellOpts.args[2])
8
+ end
9
+ ShellOpts.args would be a shorthand for ShellOpts.shellopts.args
10
+ Another option would be to create an argument-processing method:
11
+ shellopts.argv(2) -> call error if not exactly two arguments else return elements
12
+
3
13
  o Check on return value from #process block to see if all options was handled:
4
14
  case opt
5
15
  when '-v'; verbose = true # Return value 'true' is ok
@@ -11,7 +21,7 @@ TODO
11
21
  o Make an official dump method for debug
12
22
  o Make a note that all options are processed at once and not as-you-go
13
23
  o Test that arguments with spaces work
14
- o Long version usage strings
24
+ o Long version usage strings (major release)
15
25
  o Doc: Example of processing of sub-commands and sub-sub-commands
16
26
 
17
27
  + More tests
@@ -1,3 +1,3 @@
1
1
  module Shellopts
2
- VERSION = "0.9.7"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shellopts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-18 00:00:00.000000000 Z
11
+ date: 2020-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler