shellopts 0.9.7 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -10
- data/TODO +11 -1
- data/lib/shellopts/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cc3c3ef5b7b13876949b290b9d247c41778eaa38ea01432d5abac47b663478a
|
4
|
+
data.tar.gz: bc2c44f163f81d8b51545679e8f8280ac889fbb1f96a7898e5a65fa63d337d4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
11
|
-
--verbose.
|
12
|
-
|
13
|
-
|
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,
|
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,
|
198
|
+
args = ShellOpts.process(USAGE, ARGV) { |opt, arg|
|
200
199
|
case opt
|
201
200
|
when '-a'; # Handle -a
|
202
201
|
when 'cmd'
|
203
|
-
|
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,
|
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 =
|
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
|
data/lib/shellopts/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2020-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|