simple_scripting 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f48ef28748f34f32e008d951c4b4d7471e5cbe4b
4
- data.tar.gz: e6cd1cd8132eb9df036e0b5aff06ab0f8e2dd1ec
3
+ metadata.gz: d8f032bc3e5af19254d43227a9aaa57862c98738
4
+ data.tar.gz: ddcd49a81e0e7f96d38e61bf662dcda7ea7cc4e9
5
5
  SHA512:
6
- metadata.gz: fa2f35c9e810e06a1e29125650d071de636e4bb80ce3d9010a8eb74e006646f0a786cdab9311a33e0fb77d33d541c55724a78bb9ffb607a199db952dc7f28819
7
- data.tar.gz: 4e2bdc8da33f0aeede34d91dffeff61f2e420ab633d45cd408519f60becd026d35d13f0139af655c035074792626abae88e8041b1b95bf83e0b5f376f928a946
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 = SimpleOptParse::Argv.decode(
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
- command,
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
@@ -1,5 +1,5 @@
1
1
  module SimpleScripting
2
2
 
3
- VERSION = "0.9.2"
3
+ VERSION = "0.9.3"
4
4
 
5
5
  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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_scripting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saverio Miroddi