simple_scripting 0.9.2 → 0.9.3
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/README.md +16 -1
- data/lib/simple_scripting/argv.rb +7 -1
- data/lib/simple_scripting/version.rb +1 -1
- data/spec/simple_scripting/argv_spec.rb +20 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8f032bc3e5af19254d43227a9aaa57862c98738
|
4
|
+
data.tar.gz: ddcd49a81e0e7f96d38e61bf662dcda7ea7cc4e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef418ad76c9fd9c7d7509ec1198076f19315d0bbb797979f938e2ee9d960a123ccbfdb1397f0eff49699489cecdcbb76bdbccf7e807820983d16529cbc0d79e0
|
7
|
+
data.tar.gz: 2ea8945bc2b3c5cb282d6ff17df9c5ef2822d23bec986450e82b8e72341ee5e0b97afe84573b356c3abcd455d0be76e14447706dc913efa503e9da6214685161
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ This is a definition example:
|
|
21
21
|
|
22
22
|
require 'simple_scripting/argv'
|
23
23
|
|
24
|
-
result =
|
24
|
+
result = SimpleScripting::Argv.decode(
|
25
25
|
['-s', '--only-scheduled-days', 'Only print scheduled days' ],
|
26
26
|
['-d', '--print-defaults TEMPLATE', 'Print the default activities from the named template'],
|
27
27
|
'schedule',
|
@@ -57,6 +57,21 @@ This is the corresponding help:
|
|
57
57
|
|
58
58
|
This is the long help! It can span multiple lines.
|
59
59
|
|
60
|
+
Commands are also supported (with unlimited depth), by using a hash:
|
61
|
+
|
62
|
+
commands, result = SimpleScripting::Argv.decode(
|
63
|
+
'pr' => {
|
64
|
+
'create' => [
|
65
|
+
'title',
|
66
|
+
'description',
|
67
|
+
long_help: 'This is the create PR command help.'
|
68
|
+
]
|
69
|
+
},
|
70
|
+
'issues' => {
|
71
|
+
'list' => []
|
72
|
+
}
|
73
|
+
) || exit
|
74
|
+
|
60
75
|
For the guide, see the [wiki page](https://github.com/saveriomiroddi/simple_scripting/wiki/SimpleScripting::Argv-Guide).
|
61
76
|
|
62
77
|
## SimpleScripting::Configuration
|
@@ -73,7 +73,7 @@ module SimpleScripting
|
|
73
73
|
end
|
74
74
|
|
75
75
|
[
|
76
|
-
|
76
|
+
compose_returned_commands(commands_stack),
|
77
77
|
decode_arguments!(command_params_definition, arguments, commands_stack),
|
78
78
|
]
|
79
79
|
end
|
@@ -200,6 +200,12 @@ module SimpleScripting
|
|
200
200
|
raise ExitError
|
201
201
|
end
|
202
202
|
|
203
|
+
# HELPERS ##############################################
|
204
|
+
|
205
|
+
def compose_returned_commands(commands_stack)
|
206
|
+
commands_stack.join('.')
|
207
|
+
end
|
208
|
+
|
203
209
|
end
|
204
210
|
|
205
211
|
end
|
@@ -234,6 +234,26 @@ This is the long help.
|
|
234
234
|
output: output_buffer
|
235
235
|
}}
|
236
236
|
|
237
|
+
it 'should be decoded (two levels)' do
|
238
|
+
decoder_params[:arguments] = ['command1', 'nested1a', 'value1']
|
239
|
+
|
240
|
+
actual_result = described_class.decode(decoder_params)
|
241
|
+
|
242
|
+
expected_result = ['command1.nested1a', arg1: 'value1']
|
243
|
+
|
244
|
+
expect(actual_result).to eql(expected_result)
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'should be decoded (one level)' do
|
248
|
+
decoder_params[:arguments] = ['command2', 'value2']
|
249
|
+
|
250
|
+
actual_result = described_class.decode(decoder_params)
|
251
|
+
|
252
|
+
expected_result = ['command2', arg2: 'value2']
|
253
|
+
|
254
|
+
expect(actual_result).to eql(expected_result)
|
255
|
+
end
|
256
|
+
|
237
257
|
it 'should print the command1 help' do
|
238
258
|
decoder_params[:arguments] = ['command1', '-h']
|
239
259
|
|