vagrant-devcommands 0.13.0 → 0.14.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 +4 -4
- data/CHANGELOG.md +29 -48
- data/README.md +40 -62
- data/lib/vagrant/devcommands/command.rb +7 -5
- data/lib/vagrant/devcommands/commandfile/modeler.rb +3 -3
- data/lib/vagrant/devcommands/commandfile/reader.rb +10 -8
- data/lib/vagrant/devcommands/commandfile.rb +2 -0
- data/lib/vagrant/devcommands/help_printer/chain.rb +8 -6
- data/lib/vagrant/devcommands/help_printer/command.rb +8 -6
- data/lib/vagrant/devcommands/help_printer/command_alias.rb +8 -6
- data/lib/vagrant/devcommands/internal_command/completion_data.rb +2 -0
- data/lib/vagrant/devcommands/internal_command/help.rb +10 -8
- data/lib/vagrant/devcommands/internal_command/version.rb +2 -0
- data/lib/vagrant/devcommands/internal_spec.rb +12 -10
- data/lib/vagrant/devcommands/messages.rb +3 -1
- data/lib/vagrant/devcommands/model/chain.rb +3 -6
- data/lib/vagrant/devcommands/model/command.rb +16 -14
- data/lib/vagrant/devcommands/model/command_alias.rb +3 -9
- data/lib/vagrant/devcommands/param_parser.rb +6 -5
- data/lib/vagrant/devcommands/plugin.rb +2 -0
- data/lib/vagrant/devcommands/registry/messager.rb +6 -4
- data/lib/vagrant/devcommands/registry/resolver.rb +4 -8
- data/lib/vagrant/devcommands/registry/validator.rb +4 -2
- data/lib/vagrant/devcommands/registry.rb +5 -5
- data/lib/vagrant/devcommands/runner/chain.rb +2 -0
- data/lib/vagrant/devcommands/runner/command.rb +5 -3
- data/lib/vagrant/devcommands/runner/command_alias.rb +2 -0
- data/lib/vagrant/devcommands/runner/internal_command.rb +3 -1
- data/lib/vagrant/devcommands/synopsis.rb +3 -1
- data/lib/vagrant/devcommands/util/jaro_winkler.rb +5 -1
- data/lib/vagrant/devcommands/util.rb +4 -2
- data/lib/vagrant/devcommands/version.rb +3 -1
- data/lib/vagrant/devcommands.rb +2 -0
- metadata +18 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c87a4a5395ff70331bc828e00f95e4f2bd17b75dbc57561a9a512b2fa94d5402
|
4
|
+
data.tar.gz: ba566aeb333eb32fab9389b979df2f54e2326e0b98cd1beff1e94b07a52a45dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18314207fb498117756f3b0b1023c72c75c5c157408895e9d92fcc56f980039f8601f2797ca7013d0c9386f98349566662d4615f5bb329960ac895e49a4814e6
|
7
|
+
data.tar.gz: 6d92ec349743a1658fb1160b45f87c57eaf6785dba47f0c7130f4bf7249d35f40ea67897a6fdbd0b0c1fedf79711bc4d655f95e7650ea8de3e24b859d1aeb451
|
data/CHANGELOG.md
CHANGED
@@ -1,81 +1,68 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v0.14.0 (2022-08-23)
|
4
|
+
|
5
|
+
- Enhancements
|
6
|
+
- Lambda/Proc values of command scripts are now executed in the instance of the command when running
|
7
|
+
- Lambda/Proc scripts get the parsed argv values as the first (and only) argument unless defined with a zero arity
|
8
|
+
|
9
|
+
- Bug fixes
|
10
|
+
- Parameters with a default value configured will now be properly displayed as optional in the detailed command help
|
11
|
+
|
3
12
|
## v0.13.0 (2018-07-19)
|
4
13
|
|
5
14
|
- Enhancements
|
6
|
-
- Unknown parameters can be catched and used by setting
|
7
|
-
the option `passthru: true` on one of your parameters
|
8
|
-
([#3](https://github.com/mneudert/vagrant-devcommands/issues/3))
|
15
|
+
- Unknown parameters can be catched and used by setting the option `passthru: true` on one of your parameters ([#3](https://github.com/mneudert/vagrant-devcommands/issues/3))
|
9
16
|
|
10
17
|
## v0.12.0 (2018-04-21)
|
11
18
|
|
12
19
|
- Enhancements
|
13
20
|
- Command parameters can define alias values to be replaced before escaping
|
14
|
-
- Commandfile entries with duplicate names will now issue a warning while
|
15
|
-
still discarding all previous definitions
|
21
|
+
- Commandfile entries with duplicate names will now issue a warning while still discarding all previous definitions
|
16
22
|
- Commandfile entries with unknown options will issue a warning
|
17
23
|
|
18
24
|
- Backwards incompatible changes
|
19
|
-
- Support for the already deprecated configuration parameter `:box` has
|
20
|
-
been removed
|
25
|
+
- Support for the already deprecated configuration parameter `:box` has been removed
|
21
26
|
|
22
27
|
## v0.11.1 (2017-10-04)
|
23
28
|
|
24
29
|
- Bug fixes
|
25
|
-
- The machine of a command alias definition is now correctly preferred over
|
26
|
-
the machine of the command definition
|
30
|
+
- The machine of a command alias definition is now correctly preferred over the machine of the command definition
|
27
31
|
|
28
32
|
## v0.11.0 (2017-10-02)
|
29
33
|
|
30
34
|
- Enhancements
|
31
|
-
- Command aliases can be used to provide multiple ways to call a single
|
32
|
-
command including automatically populated arguments
|
35
|
+
- Command aliases can be used to provide multiple ways to call a single command including automatically populated arguments
|
33
36
|
- Commands can define if they need a tty by using the new `:tty` option
|
34
37
|
|
35
38
|
- Backwards incompatible changes
|
36
|
-
- By default a command does not use a tty. This potentially breaks commands
|
37
|
-
requiring one, e.g. a mysql console command
|
39
|
+
- By default a command does not use a tty. This potentially breaks commands requiring one, e.g. a mysql console command
|
38
40
|
|
39
41
|
## v0.10.1 (2017-08-08)
|
40
42
|
|
41
43
|
- Bug fixes
|
42
|
-
- Vagrant introduced a tty flag for ssh command execution in version `1.9.6`.
|
43
|
-
This broke some commands requiring an interactive terminal
|
44
|
-
(like a mysql client). This flag is now permanently active to restore the
|
45
|
-
function of these commands until the next regular release introduces a
|
46
|
-
full per command tty configuration
|
44
|
+
- Vagrant introduced a tty flag for ssh command execution in version `1.9.6`. This broke some commands requiring an interactive terminal (like a mysql client). This flag is now permanently active to restore the function of these commands until the next regular release introduces a full per command tty configuration
|
47
45
|
|
48
46
|
## v0.10.0 (2017-07-02)
|
49
47
|
|
50
48
|
- Enhancements
|
51
|
-
- Command alternatives provided by the "did-you-mean" feature no longer
|
52
|
-
|
53
|
-
-
|
54
|
-
will be presented instead of a full command list (help)
|
55
|
-
- Minimal data for shell completion is available via the internal
|
56
|
-
`completion-data` command
|
49
|
+
- Command alternatives provided by the "did-you-mean" feature no longer display the full command list (help)
|
50
|
+
- Depending on the internal scoring multiple alternative commands will be presented instead of a full command list (help)
|
51
|
+
- Minimal data for shell completion is available via the internal `completion-data` command
|
57
52
|
- Parameters can limit the values you are allowed to pass in
|
58
|
-
- Spaces in chain/command names are now officially disallowed. Those
|
59
|
-
would have always been broken anyways, but now there is a nice message
|
60
|
-
and the commands are excluded from the various listings
|
53
|
+
- Spaces in chain/command names are now officially disallowed. Those would have always been broken anyways, but now there is a nice message and the commands are excluded from the various listings
|
61
54
|
|
62
55
|
- Bug fixes
|
63
|
-
- Chain names can no longer conflict with internal commands like `help`
|
64
|
-
or `version`. The respective chain definitions are dropped and a warning
|
65
|
-
is issued
|
56
|
+
- Chain names can no longer conflict with internal commands like `help` or `version`. The respective chain definitions are dropped and a warning is issued
|
66
57
|
|
67
58
|
## v0.9.0 (2017-05-20)
|
68
59
|
|
69
60
|
- Enhancements
|
70
61
|
- Every command in a chain can specify the machine to be used
|
71
|
-
- If an unknown command is requested a possible alternative
|
72
|
-
is suggested based on the calculated
|
73
|
-
[Jaro-Winkler distance](https://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance)
|
62
|
+
- If an unknown command is requested a possible alternative is suggested based on the calculated [Jaro-Winkler distance](https://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance)
|
74
63
|
|
75
64
|
- Deprecations
|
76
|
-
- The configuration parameter `:box` has been renamed to `:machine` to
|
77
|
-
match the vagrant naming. Support for the old configuration will be
|
78
|
-
dropped in a future version
|
65
|
+
- The configuration parameter `:box` has been renamed to `:machine` to match the Vagrant naming. Support for the old configuration will be dropped in a future version
|
79
66
|
|
80
67
|
## v0.8.0 (2017-04-19)
|
81
68
|
|
@@ -86,14 +73,12 @@
|
|
86
73
|
## v0.7.2 (2017-03-12)
|
87
74
|
|
88
75
|
- Bug fixes
|
89
|
-
- Machine names passed via argv are properly detected and used
|
90
|
-
([#1](https://github.com/mneudert/vagrant-devcommands/pull/1))
|
76
|
+
- Machine names passed via argv are properly detected and used ([#1](https://github.com/mneudert/vagrant-devcommands/pull/1))
|
91
77
|
|
92
78
|
## v0.7.1 (2017-02-15)
|
93
79
|
|
94
80
|
- Bug fixes
|
95
|
-
- Wrapping of optional parameters should now properly be done only if
|
96
|
-
at least an empty string is defined as a default value
|
81
|
+
- Wrapping of optional parameters should now properly be done only if at least an empty string is defined as a default value
|
97
82
|
|
98
83
|
## v0.7.0 (2016-09-26)
|
99
84
|
|
@@ -106,16 +91,12 @@
|
|
106
91
|
- Enhancements
|
107
92
|
- Command usage now displays the correct parameter syntax
|
108
93
|
- Command usage always displays mandatory parameters before optional ones
|
109
|
-
- Error output (e.g. "missing Commandfile") is now printed using
|
110
|
-
|
111
|
-
- Global commands can be defined using a file
|
112
|
-
named `.vagrant.devcommands` located under `Dir.home()`
|
94
|
+
- Error output (e.g. "missing Commandfile") is now printed using the configured ui class (allows colored output)
|
95
|
+
- Global commands can be defined using a file named `.vagrant.devcommands` located under `Dir.home()`
|
113
96
|
- Invalid parameters are displayed in the error message
|
114
97
|
- Missing parameters are displayed in the error message
|
115
|
-
- Parameter wrapping is only done if a value is passed
|
116
|
-
|
117
|
-
- Warnings about using internal command names or missing scripts are now
|
118
|
-
printed using the configured ui class (allows colored output)
|
98
|
+
- Parameter wrapping is only done if a value is passed or a default (at least empty string) is configured
|
99
|
+
- Warnings about using internal command names or missing scripts are now printed using the configured ui class (allows colored output)
|
119
100
|
|
120
101
|
## v0.5.0 (2016-03-21)
|
121
102
|
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Vagrant DevCommands
|
2
2
|
|
3
|
-
Runs
|
3
|
+
Runs Vagrant commands from a Commandfile.
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
@@ -45,19 +45,15 @@ of the command name using either %{command} or %<command>s.
|
|
45
45
|
eoh
|
46
46
|
```
|
47
47
|
|
48
|
-
_Note_: If you are defining literal `%` (percent sign) in your commands you
|
49
|
-
have to escape them using a second `%`. For example `date '+%%Y-%%m-%%d'`.
|
48
|
+
_Note_: If you are defining literal `%` (percent sign) in your commands you have to escape them using a second `%`. For example `date '+%%Y-%%m-%%d'`.
|
50
49
|
|
51
|
-
_Note_: Spaces in command names are not supported. Definitions with spaces will
|
52
|
-
be ignored.
|
50
|
+
_Note_: Spaces in command names are not supported. Definitions with spaces will be ignored.
|
53
51
|
|
54
|
-
_Note_: Please be aware that setting a custom `usage` hides the original usage
|
55
|
-
line from the help output.
|
52
|
+
_Note_: Please be aware that setting a custom `usage` hides the original usage line from the help output.
|
56
53
|
|
57
54
|
#### Commands with Parameters
|
58
55
|
|
59
|
-
Passing additional parameters to a command is (minimally) supported using an
|
60
|
-
sprintf syntax:
|
56
|
+
Passing additional parameters to a command is (minimally) supported using an sprintf syntax:
|
61
57
|
|
62
58
|
```ruby
|
63
59
|
command 'with_param',
|
@@ -120,18 +116,13 @@ vagrant run with_param \
|
|
120
116
|
--p_limited completely
|
121
117
|
```
|
122
118
|
|
123
|
-
For now a command expecting one or more parameters will fail if the user does
|
124
|
-
not provide them. Any arguments exceeding the number used are silently
|
125
|
-
discarded.
|
119
|
+
For now a command expecting one or more parameters will fail if the user does not provide them. Any arguments exceeding the number used are silently discarded.
|
126
120
|
|
127
|
-
Escaping rules are defined as `{ 'char_to_escape' => 'char_to_use_as_escape' }`.
|
128
|
-
These are applied prior to interpolation into the command. Regular ruby escaping
|
129
|
-
rules apply.
|
121
|
+
Escaping rules are defined as `{ 'char_to_escape' => 'char_to_use_as_escape' }`. These are applied prior to interpolation into the command. Regular ruby escaping rules apply.
|
130
122
|
|
131
123
|
#### Commands with Flags
|
132
124
|
|
133
|
-
Every command can be associated with (by definition optional) flags available
|
134
|
-
for later command interpolation:
|
125
|
+
Every command can be associated with (by definition optional) flags available for later command interpolation:
|
135
126
|
|
136
127
|
```ruby
|
137
128
|
command 'with_flags',
|
@@ -155,27 +146,36 @@ vagrant run with_flags --f_standard
|
|
155
146
|
vagrant run with_flags --f_valued
|
156
147
|
```
|
157
148
|
|
158
|
-
By default a flag gets interpolated as `--#{flagname}`. If a value is defined
|
159
|
-
this value will be interpolated unmodified.
|
149
|
+
By default a flag gets interpolated as `--#{flagname}`. If a value is defined this value will be interpolated unmodified.
|
160
150
|
|
161
151
|
#### Commands defined by Lambda/Proc
|
162
152
|
|
163
|
-
You can (more or less) dynamically generate your scripts by defining the
|
164
|
-
command with a lambda or proc as its script.
|
153
|
+
You can (more or less) dynamically generate your scripts by defining the command with a lambda or proc as its script.
|
165
154
|
|
166
155
|
```ruby
|
167
156
|
command 'from_lambda', script: lambda { 'echo "lambda works"' }
|
168
157
|
command 'from_proc', script: proc { 'echo "proc works"' }
|
158
|
+
|
159
|
+
command 'from_lambda_params',
|
160
|
+
parameters: { argv_param: {} },
|
161
|
+
script: lambda { |params|
|
162
|
+
'echo "lambda works: ' + params[:argv_param] + '"'
|
163
|
+
}
|
164
|
+
|
165
|
+
command 'from_proc_params',
|
166
|
+
parameters: { argv_param: {} },
|
167
|
+
script: proc { |params|
|
168
|
+
'echo "proc works: ' + params[:argv_param] + '"'
|
169
|
+
}
|
169
170
|
```
|
170
171
|
|
171
|
-
These will be evaluated when running the command.
|
172
|
+
These will be evaluated when running the command and optionally received the parsed shell arguments when defined with an arity of one.
|
172
173
|
|
173
174
|
Every rule from regular scripts (parameters, escaping `%`, ...) still apply.
|
174
175
|
|
175
176
|
#### Commands with a TTY ("interactive")
|
176
177
|
|
177
|
-
If you have a command that expects some sort of interaction with the user you
|
178
|
-
may need to set the `tty` option for a command:
|
178
|
+
If you have a command that expects some sort of interaction with the user you may need to set the `tty` option for a command:
|
179
179
|
|
180
180
|
```ruby
|
181
181
|
command 'interactive', tty: true
|
@@ -185,9 +185,7 @@ This allows full interaction with programs like `irb` or `mysql`.
|
|
185
185
|
|
186
186
|
### Global Command Definitions
|
187
187
|
|
188
|
-
To have commands available even wihout a `Commandfile` you can define the
|
189
|
-
globally. To do this just create a file named `.vagrant.devcommands` in your
|
190
|
-
`$HOME` directory.
|
188
|
+
To have commands available even wihout a `Commandfile` you can define the globally. To do this just create a file named `.vagrant.devcommands` in your `$HOME` directory.
|
191
189
|
|
192
190
|
You can use this command to find the correct path if unsure:
|
193
191
|
|
@@ -218,20 +216,15 @@ eoh
|
|
218
216
|
|
219
217
|
The configured commands will be executed in the order defined.
|
220
218
|
|
221
|
-
If one or more of your commands requires parameters all of them have to be
|
222
|
-
passed to the chain execution.
|
219
|
+
If one or more of your commands requires parameters all of them have to be passed to the chain execution.
|
223
220
|
|
224
|
-
By default a chain breaks upon the first non-zero return value of any
|
225
|
-
configured command. To deactivate this behaviour you can set `:break_on_error`
|
226
|
-
to `false`. Any value other than `false` will stick to the default.
|
221
|
+
By default a chain breaks upon the first non-zero return value of any configured command. To deactivate this behaviour you can set `:break_on_error` to `false`. Any value other than `false` will stick to the default.
|
227
222
|
|
228
|
-
_Note_: Spaces in command names are not supported. Definitions with spaces will
|
229
|
-
be ignored.
|
223
|
+
_Note_: Spaces in command names are not supported. Definitions with spaces will be ignored.
|
230
224
|
|
231
225
|
#### Chain Definitions with Pre-Defined Parameters
|
232
226
|
|
233
|
-
If required you can modify the arguments given to each chain element by setting
|
234
|
-
additional/custom argv values for a single chain element:
|
227
|
+
If required you can modify the arguments given to each chain element by setting additional/custom argv values for a single chain element:
|
235
228
|
|
236
229
|
```ruby
|
237
230
|
command 'chainecho',
|
@@ -256,9 +249,7 @@ vagrant run chainecho --first='initial' --second='initial'
|
|
256
249
|
vagrant run chainecho --first='param' --second='param'
|
257
250
|
```
|
258
251
|
|
259
|
-
By default every command will be executed using the machine defined by the
|
260
|
-
command itself or the only one available. You can, however, run the complete
|
261
|
-
chain against a specific machine using `vagrant run your_machine your_chain`.
|
252
|
+
By default every command will be executed using the machine defined by the command itself or the only one available. You can, however, run the complete chain against a specific machine using `vagrant run your_machine your_chain`.
|
262
253
|
|
263
254
|
#### Chain Definitions with Specific Machines
|
264
255
|
|
@@ -286,13 +277,11 @@ vagrant run secondary chainhost
|
|
286
277
|
vagrant run tertiary chainhost
|
287
278
|
```
|
288
279
|
|
289
|
-
This configuration can itself be modified by passing a machine name to run
|
290
|
-
all chain commands on using using `vagrant run your_machine your_chain`.
|
280
|
+
This configuration can itself be modified by passing a machine name to run all chain commands on using using `vagrant run your_machine your_chain`.
|
291
281
|
|
292
282
|
### Abort Parsing inside Commandfile
|
293
283
|
|
294
|
-
If you, for whatever reasons, want to abort further parsing of a `Commandfile`
|
295
|
-
you can simple return from it:
|
284
|
+
If you, for whatever reasons, want to abort further parsing of a `Commandfile` you can simple return from it:
|
296
285
|
|
297
286
|
```ruby
|
298
287
|
command 'foo', script: 'foo'
|
@@ -307,16 +296,13 @@ return if v_cur < v_min
|
|
307
296
|
command 'bar', script: 'bar'
|
308
297
|
```
|
309
298
|
|
310
|
-
This example leads to the command `bar` not being available if the currently
|
311
|
-
installed plugin has a version below `1.3.3.7`.
|
299
|
+
This example leads to the command `bar` not being available if the currently installed plugin has a version below `1.3.3.7`.
|
312
300
|
|
313
|
-
Please be aware that returning from a global commandfile completely skips
|
314
|
-
evaluating a local one.
|
301
|
+
Please be aware that returning from a global commandfile completely skips evaluating a local one.
|
315
302
|
|
316
303
|
### Command Alias Definitions
|
317
304
|
|
318
|
-
For commands you want to keep generic but often call with a specific set of
|
319
|
-
parameter values you can define an alias:
|
305
|
+
For commands you want to keep generic but often call with a specific set of parameter values you can define an alias:
|
320
306
|
|
321
307
|
```ruby
|
322
308
|
command 'customecho',
|
@@ -334,9 +320,7 @@ I get displayed when running "vagrant run help aliasecho".
|
|
334
320
|
eoh
|
335
321
|
```
|
336
322
|
|
337
|
-
The setting `command` is required, the other options `argv` and `machine` are
|
338
|
-
optional and used for the actual customization. Any argument configured will
|
339
|
-
take precedence over the value given to `vagrant run` itself.
|
323
|
+
The setting `command` is required, the other options `argv` and `machine` are optional and used for the actual customization. Any argument configured will take precedence over the value given to `vagrant run` itself.
|
340
324
|
|
341
325
|
### Experimental: Shell Completion
|
342
326
|
|
@@ -354,14 +338,11 @@ vagrant run completion-data my-command
|
|
354
338
|
|
355
339
|
### SSH
|
356
340
|
|
357
|
-
If you are using this plugin on a Windows host system, please make sure your
|
358
|
-
regular `vagrant ssh [machine]` succeeds. In some cases you may need to add the
|
359
|
-
`ssh.exe` (e.g. from a git installation) manually to your `%PATH%`.
|
341
|
+
If you are using this plugin on a Windows host system, please make sure your regular `vagrant ssh [machine]` succeeds. In some cases you may need to add the `ssh.exe` (e.g. from a git installation) manually to your `%PATH%`.
|
360
342
|
|
361
343
|
### Command Definition
|
362
344
|
|
363
|
-
When using multi-line commands you probably need to define your command using
|
364
|
-
a sigil notation like the following:
|
345
|
+
When using multi-line commands you probably need to define your command using a sigil notation like the following:
|
365
346
|
|
366
347
|
```ruby
|
367
348
|
command 'long_running_task',
|
@@ -371,12 +352,9 @@ command 'long_running_task',
|
|
371
352
|
&& echo 'finished long running task')
|
372
353
|
```
|
373
354
|
|
374
|
-
Using a quote delimited command definition might otherwise result in not that
|
375
|
-
helpful error messages about a bad shell command.
|
355
|
+
Using a quote delimited command definition might otherwise result in not that helpful error messages about a bad shell command.
|
376
356
|
|
377
|
-
It might also help to double check the line endings in your Commandfile are set
|
378
|
-
unix-style (`\n`) and not windows-style (`\r\n`) if you get errors when running
|
379
|
-
your commands.
|
357
|
+
It might also help to double check the line endings in your Commandfile are set unix-style (`\n`) and not windows-style (`\r\n`) if you get errors when running your commands.
|
380
358
|
|
381
359
|
## Development
|
382
360
|
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
# Defines the executable vagrant command
|
4
6
|
class Command < Vagrant.plugin(2, :command)
|
5
|
-
I18N_KEY = 'vagrant_devcommands.'
|
7
|
+
I18N_KEY = 'vagrant_devcommands.'
|
6
8
|
|
7
9
|
def self.synopsis
|
8
10
|
synopsis = VagrantPlugins::DevCommands::SYNOPSIS
|
@@ -52,15 +54,15 @@ module VagrantPlugins
|
|
52
54
|
return false if alternatives.empty?
|
53
55
|
|
54
56
|
if alternatives.length == 1
|
55
|
-
display_error(I18n.t("#{I18N_KEY}.did_you_mean_single"), true)
|
57
|
+
display_error(I18n.t("#{I18N_KEY}.did_you_mean_single"), pre_ln: true)
|
56
58
|
else
|
57
|
-
display_error(I18n.t("#{I18N_KEY}.did_you_mean_multi"), true)
|
59
|
+
display_error(I18n.t("#{I18N_KEY}.did_you_mean_multi"), pre_ln: true)
|
58
60
|
end
|
59
61
|
|
60
62
|
alternatives.sort.each { |(k, _v)| display_error(" #{k}") }
|
61
63
|
end
|
62
64
|
|
63
|
-
def display_error(msg, pre_ln
|
65
|
+
def display_error(msg, pre_ln: false, post_ln: false)
|
64
66
|
@env.ui.error '' if pre_ln
|
65
67
|
@env.ui.error msg
|
66
68
|
@env.ui.error '' if post_ln
|
@@ -96,7 +98,7 @@ module VagrantPlugins
|
|
96
98
|
|
97
99
|
runner.run(runnable)
|
98
100
|
rescue RuntimeError => e
|
99
|
-
display_error(e.message,
|
101
|
+
display_error(e.message, post_ln: true)
|
100
102
|
run_internal('help', [command])
|
101
103
|
|
102
104
|
nil
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
class Commandfile
|
@@ -33,9 +35,7 @@ module VagrantPlugins
|
|
33
35
|
options = { script: options } unless options.is_a?(Hash)
|
34
36
|
options[:name] = name
|
35
37
|
|
36
|
-
unless valid_script?(options[:script])
|
37
|
-
raise ArgumentError, 'command_no_script'
|
38
|
-
end
|
38
|
+
raise ArgumentError, 'command_no_script' unless valid_script?(options[:script])
|
39
39
|
|
40
40
|
VagrantPlugins::DevCommands::Model::Command.new(options)
|
41
41
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
class Commandfile
|
@@ -17,8 +19,8 @@ module VagrantPlugins
|
|
17
19
|
local = @commandfile.path
|
18
20
|
|
19
21
|
contents = ''
|
20
|
-
contents += "\n
|
21
|
-
contents += "\n
|
22
|
+
contents += "\n#{global.read}" unless global.nil?
|
23
|
+
contents += "\n#{local.read}" unless local.nil?
|
22
24
|
|
23
25
|
instance_eval(contents)
|
24
26
|
|
@@ -29,24 +31,24 @@ module VagrantPlugins
|
|
29
31
|
|
30
32
|
def chain(name, options = nil)
|
31
33
|
@entries << {
|
32
|
-
type:
|
33
|
-
name:
|
34
|
+
type: :chain,
|
35
|
+
name: name.to_s,
|
34
36
|
options: options
|
35
37
|
}
|
36
38
|
end
|
37
39
|
|
38
40
|
def command(name, options = nil)
|
39
41
|
@entries << {
|
40
|
-
type:
|
41
|
-
name:
|
42
|
+
type: :command,
|
43
|
+
name: name.to_s,
|
42
44
|
options: options
|
43
45
|
}
|
44
46
|
end
|
45
47
|
|
46
48
|
def command_alias(name, options = nil)
|
47
49
|
@entries << {
|
48
|
-
type:
|
49
|
-
name:
|
50
|
+
type: :command_alias,
|
51
|
+
name: name.to_s,
|
50
52
|
options: options
|
51
53
|
}
|
52
54
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
module HelpPrinter
|
4
6
|
# Prints help for a command chain
|
5
7
|
class Chain
|
6
|
-
I18N_KEY = 'vagrant_devcommands.internal.help'
|
8
|
+
I18N_KEY = 'vagrant_devcommands.internal.help'
|
7
9
|
UTIL = VagrantPlugins::DevCommands::Util
|
8
10
|
MESSAGES = VagrantPlugins::DevCommands::Messages
|
9
11
|
|
@@ -20,9 +22,9 @@ module VagrantPlugins
|
|
20
22
|
private
|
21
23
|
|
22
24
|
def body(help)
|
23
|
-
return message(:chain_no_help, true) if help.nil?
|
25
|
+
return message(:chain_no_help, pre_ln: true) if help.nil?
|
24
26
|
|
25
|
-
info(help.strip, true)
|
27
|
+
info(help.strip, pre_ln: true)
|
26
28
|
end
|
27
29
|
|
28
30
|
def chain_help_line(cmd)
|
@@ -32,7 +34,7 @@ module VagrantPlugins
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def commands(chain)
|
35
|
-
info('Chained commands (in order):', true)
|
37
|
+
info('Chained commands (in order):', pre_ln: true)
|
36
38
|
|
37
39
|
chain.commands.each do |cmd|
|
38
40
|
info(UTIL.padded_columns(0, chain_help_line(cmd)))
|
@@ -50,12 +52,12 @@ module VagrantPlugins
|
|
50
52
|
info(I18n.t("#{I18N_KEY}.usage", what: usage))
|
51
53
|
end
|
52
54
|
|
53
|
-
def info(msg, pre_ln
|
55
|
+
def info(msg, pre_ln: false)
|
54
56
|
@env.ui.info '' if pre_ln
|
55
57
|
@env.ui.info msg
|
56
58
|
end
|
57
59
|
|
58
|
-
def message(msg, pre_ln
|
60
|
+
def message(msg, pre_ln: false)
|
59
61
|
if pre_ln
|
60
62
|
MESSAGES.pre_ln(msg, &@env.ui.method(:info))
|
61
63
|
else
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
module HelpPrinter
|
4
6
|
# Prints help for a command
|
5
7
|
class Command
|
6
|
-
I18N_KEY = 'vagrant_devcommands.internal.help'
|
8
|
+
I18N_KEY = 'vagrant_devcommands.internal.help'
|
7
9
|
UTIL = VagrantPlugins::DevCommands::Util
|
8
10
|
MESSAGES = VagrantPlugins::DevCommands::Messages
|
9
11
|
|
@@ -23,7 +25,7 @@ module VagrantPlugins
|
|
23
25
|
def arguments(arguments, title)
|
24
26
|
return if arguments.nil? || arguments.empty?
|
25
27
|
|
26
|
-
info("#{title}:", true)
|
28
|
+
info("#{title}:", pre_ln: true)
|
27
29
|
arguments_body(arguments)
|
28
30
|
end
|
29
31
|
|
@@ -36,9 +38,9 @@ module VagrantPlugins
|
|
36
38
|
end
|
37
39
|
|
38
40
|
def body(help)
|
39
|
-
return message(:command_no_help, true) if help.nil?
|
41
|
+
return message(:command_no_help, pre_ln: true) if help.nil?
|
40
42
|
|
41
|
-
info(help.strip, true)
|
43
|
+
info(help.strip, pre_ln: true)
|
42
44
|
end
|
43
45
|
|
44
46
|
def header(command)
|
@@ -55,12 +57,12 @@ module VagrantPlugins
|
|
55
57
|
info(I18n.t("#{I18N_KEY}.usage", what: usage))
|
56
58
|
end
|
57
59
|
|
58
|
-
def info(msg, pre_ln
|
60
|
+
def info(msg, pre_ln: false)
|
59
61
|
@env.ui.info '' if pre_ln
|
60
62
|
@env.ui.info msg
|
61
63
|
end
|
62
64
|
|
63
|
-
def message(msg, pre_ln
|
65
|
+
def message(msg, pre_ln: false)
|
64
66
|
if pre_ln
|
65
67
|
MESSAGES.pre_ln(msg, &@env.ui.method(:info))
|
66
68
|
else
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
module HelpPrinter
|
4
6
|
# Prints help for a command alias
|
5
7
|
class CommandAlias
|
6
|
-
I18N_KEY = 'vagrant_devcommands.internal.help'
|
8
|
+
I18N_KEY = 'vagrant_devcommands.internal.help'
|
7
9
|
UTIL = VagrantPlugins::DevCommands::Util
|
8
10
|
MESSAGES = VagrantPlugins::DevCommands::Messages
|
9
11
|
|
@@ -19,9 +21,9 @@ module VagrantPlugins
|
|
19
21
|
private
|
20
22
|
|
21
23
|
def body(help)
|
22
|
-
return message(:command_alias_no_help, true) if help.nil?
|
24
|
+
return message(:command_alias_no_help, pre_ln: true) if help.nil?
|
23
25
|
|
24
|
-
info(help.strip, true)
|
26
|
+
info(help.strip, pre_ln: true)
|
25
27
|
end
|
26
28
|
|
27
29
|
def header(command_alias)
|
@@ -35,15 +37,15 @@ module VagrantPlugins
|
|
35
37
|
alias_for = [command_alias.command, command_alias.argv].join(' ')
|
36
38
|
|
37
39
|
info(I18n.t("#{I18N_KEY}.usage", what: usage))
|
38
|
-
info(I18n.t("#{I18N_KEY}.alias_for", what: alias_for), true)
|
40
|
+
info(I18n.t("#{I18N_KEY}.alias_for", what: alias_for), pre_ln: true)
|
39
41
|
end
|
40
42
|
|
41
|
-
def info(msg, pre_ln
|
43
|
+
def info(msg, pre_ln: false)
|
42
44
|
@env.ui.info '' if pre_ln
|
43
45
|
@env.ui.info msg
|
44
46
|
end
|
45
47
|
|
46
|
-
def message(msg, pre_ln
|
48
|
+
def message(msg, pre_ln: false)
|
47
49
|
if pre_ln
|
48
50
|
MESSAGES.pre_ln(msg, &@env.ui.method(:info))
|
49
51
|
else
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
module InternalCommand
|
4
6
|
# Internal "help" command
|
5
7
|
class Help
|
6
|
-
I18N_KEY = 'vagrant_devcommands.internal.help'
|
8
|
+
I18N_KEY = 'vagrant_devcommands.internal.help'
|
7
9
|
UTIL = VagrantPlugins::DevCommands::Util
|
8
10
|
MESSAGES = VagrantPlugins::DevCommands::Messages
|
9
11
|
PRINTER = VagrantPlugins::DevCommands::HelpPrinter
|
@@ -38,7 +40,7 @@ module VagrantPlugins
|
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
41
|
-
def info(msg, pre_ln
|
43
|
+
def info(msg, pre_ln: false)
|
42
44
|
@env.ui.info '' if pre_ln
|
43
45
|
@env.ui.info msg
|
44
46
|
end
|
@@ -49,9 +51,9 @@ module VagrantPlugins
|
|
49
51
|
|
50
52
|
def internal_help(command)
|
51
53
|
internal_help_header(command)
|
52
|
-
info(internal_commands[command].help.strip, true)
|
54
|
+
info(internal_commands[command].help.strip, pre_ln: true)
|
53
55
|
|
54
|
-
message(:plugin_readme, true) if command == 'help'
|
56
|
+
message(:plugin_readme, pre_ln: true) if command == 'help'
|
55
57
|
end
|
56
58
|
|
57
59
|
def internal_help_header(command)
|
@@ -68,7 +70,7 @@ module VagrantPlugins
|
|
68
70
|
@registry.commands])
|
69
71
|
end
|
70
72
|
|
71
|
-
def message(msg, pre_ln
|
73
|
+
def message(msg, pre_ln: false)
|
72
74
|
if pre_ln
|
73
75
|
MESSAGES.pre_ln(msg, &@env.ui.method(:info))
|
74
76
|
else
|
@@ -90,7 +92,7 @@ module VagrantPlugins
|
|
90
92
|
def plugin_help_chains(chains, pad_to)
|
91
93
|
return if chains.empty?
|
92
94
|
|
93
|
-
info(I18n.t("#{I18N_KEY}.list.chains"), true)
|
95
|
+
info(I18n.t("#{I18N_KEY}.list.chains"), pre_ln: true)
|
94
96
|
|
95
97
|
chains.sort.each do |name, chain|
|
96
98
|
info(UTIL.padded_columns(pad_to, name, chain.desc))
|
@@ -100,7 +102,7 @@ module VagrantPlugins
|
|
100
102
|
def plugin_help_commands(type, commands, pad_to)
|
101
103
|
return if commands.empty?
|
102
104
|
|
103
|
-
info(I18n.t("#{I18N_KEY}.list.commands_#{type}"), true)
|
105
|
+
info(I18n.t("#{I18N_KEY}.list.commands_#{type}"), pre_ln: true)
|
104
106
|
|
105
107
|
commands.sort.each do |name, command|
|
106
108
|
info(UTIL.padded_columns(pad_to, name, command.desc))
|
@@ -110,7 +112,7 @@ module VagrantPlugins
|
|
110
112
|
def plugin_help_command_aliases(command_aliases, pad_to)
|
111
113
|
return if command_aliases.empty?
|
112
114
|
|
113
|
-
info(I18n.t("#{I18N_KEY}.list.command_aliases"), true)
|
115
|
+
info(I18n.t("#{I18N_KEY}.list.command_aliases"), pre_ln: true)
|
114
116
|
|
115
117
|
command_aliases.sort.each do |name, command_alias|
|
116
118
|
info(UTIL.padded_columns(pad_to, name, command_alias.desc))
|
@@ -1,28 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
# Contains the specs for internal commands
|
4
6
|
class InternalSpec
|
5
|
-
I18N_KEY = 'vagrant_devcommands.internal'
|
7
|
+
I18N_KEY = 'vagrant_devcommands.internal'
|
6
8
|
|
7
9
|
COMPLETION_DATA = {
|
8
|
-
desc:
|
9
|
-
name:
|
10
|
+
desc: I18n.t("#{I18N_KEY}.completion-data.desc"),
|
11
|
+
name: 'completion-data',
|
10
12
|
usage: 'vagrant run %<command>s',
|
11
|
-
help:
|
13
|
+
help: I18n.t("#{I18N_KEY}.completion-data.help")
|
12
14
|
}.freeze
|
13
15
|
|
14
16
|
HELP = {
|
15
|
-
desc:
|
16
|
-
name:
|
17
|
+
desc: I18n.t("#{I18N_KEY}.help.desc"),
|
18
|
+
name: 'help',
|
17
19
|
usage: 'vagrant run %<command>s [command]',
|
18
|
-
help:
|
20
|
+
help: I18n.t("#{I18N_KEY}.help.help")
|
19
21
|
}.freeze
|
20
22
|
|
21
23
|
VERSION = {
|
22
|
-
desc:
|
23
|
-
name:
|
24
|
+
desc: I18n.t("#{I18N_KEY}.version.desc"),
|
25
|
+
name: 'version',
|
24
26
|
usage: 'vagrant run %<command>s',
|
25
|
-
help:
|
27
|
+
help: I18n.t("#{I18N_KEY}.version.help")
|
26
28
|
}.freeze
|
27
29
|
end
|
28
30
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'optparse'
|
2
4
|
|
3
5
|
module VagrantPlugins
|
4
6
|
module DevCommands
|
5
7
|
# Provides access to messages used by the plugin
|
6
8
|
class Messages
|
7
|
-
I18N_KEY = 'vagrant_devcommands.message'
|
9
|
+
I18N_KEY = 'vagrant_devcommands.message'
|
8
10
|
|
9
11
|
def self.chain_no_help(&out)
|
10
12
|
out.call I18n.t("#{I18N_KEY}.chain_no_help")
|
@@ -1,14 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
module Model
|
4
6
|
# Definition of an executable command chain
|
5
7
|
class Chain
|
6
|
-
attr_reader :name
|
7
|
-
attr_reader :commands
|
8
|
-
|
9
|
-
attr_reader :desc
|
10
|
-
attr_reader :help
|
11
|
-
attr_reader :usage
|
8
|
+
attr_reader :name, :commands, :desc, :help, :usage
|
12
9
|
|
13
10
|
def initialize(spec)
|
14
11
|
@name = spec[:name]
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
module Model
|
@@ -5,17 +7,7 @@ module VagrantPlugins
|
|
5
7
|
class Command
|
6
8
|
PARAM_PARSER = VagrantPlugins::DevCommands::ParamParser
|
7
9
|
|
8
|
-
attr_reader :name
|
9
|
-
|
10
|
-
attr_reader :flags
|
11
|
-
attr_reader :parameters
|
12
|
-
attr_reader :script
|
13
|
-
attr_reader :tty
|
14
|
-
|
15
|
-
attr_reader :machine
|
16
|
-
attr_reader :desc
|
17
|
-
attr_reader :help
|
18
|
-
attr_reader :usage
|
10
|
+
attr_reader :name, :flags, :parameters, :script, :tty, :machine, :desc, :help, :usage
|
19
11
|
|
20
12
|
def initialize(spec)
|
21
13
|
@name = spec[:name]
|
@@ -32,14 +24,24 @@ module VagrantPlugins
|
|
32
24
|
end
|
33
25
|
|
34
26
|
def run_script(argv)
|
35
|
-
script = @script
|
36
|
-
script = script.call if script.is_a?(Proc)
|
37
|
-
|
38
27
|
param_parser = PARAM_PARSER.new
|
39
28
|
params = param_parser.parse!(self, argv)
|
40
29
|
|
30
|
+
script = @script
|
31
|
+
script = eval_script_proc(script, params) if script.is_a?(Proc)
|
32
|
+
|
41
33
|
(script % params).strip
|
42
34
|
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def eval_script_proc(script, params)
|
39
|
+
if script.arity == 1
|
40
|
+
instance_exec(params, &script)
|
41
|
+
else
|
42
|
+
instance_exec(&script)
|
43
|
+
end
|
44
|
+
end
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'optparse'
|
2
4
|
|
3
5
|
module VagrantPlugins
|
@@ -5,15 +7,7 @@ module VagrantPlugins
|
|
5
7
|
module Model
|
6
8
|
# Definition of a command alias
|
7
9
|
class CommandAlias
|
8
|
-
attr_reader :name
|
9
|
-
|
10
|
-
attr_reader :argv
|
11
|
-
attr_reader :command
|
12
|
-
|
13
|
-
attr_reader :machine
|
14
|
-
attr_reader :desc
|
15
|
-
attr_reader :help
|
16
|
-
attr_reader :usage
|
10
|
+
attr_reader :name, :argv, :command, :machine, :desc, :help, :usage
|
17
11
|
|
18
12
|
def initialize(spec)
|
19
13
|
@name = spec[:name]
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'optparse'
|
2
4
|
|
3
5
|
module VagrantPlugins
|
@@ -11,8 +13,7 @@ module VagrantPlugins
|
|
11
13
|
params = unalias_parameters(command, params)
|
12
14
|
params = validate_parameters(command, params)
|
13
15
|
params = escape_parameters(command, params)
|
14
|
-
|
15
|
-
params
|
16
|
+
wrap_parameters(command, params)
|
16
17
|
end
|
17
18
|
|
18
19
|
private
|
@@ -41,6 +42,7 @@ module VagrantPlugins
|
|
41
42
|
params
|
42
43
|
end
|
43
44
|
|
45
|
+
# rubocop:disable Metrics/AbcSize
|
44
46
|
# rubocop:disable Metrics/MethodLength
|
45
47
|
def parse_argv(command, argv)
|
46
48
|
params = parameters_with_defaults(command)
|
@@ -68,6 +70,7 @@ module VagrantPlugins
|
|
68
70
|
params = passthru_parameters(params, command, argv) unless argv.empty?
|
69
71
|
params
|
70
72
|
end
|
73
|
+
# rubocop:enable Metrics/AbcSize
|
71
74
|
# rubocop:enable Metrics/MethodLength
|
72
75
|
|
73
76
|
def passthru_parameters(params, command, argv)
|
@@ -116,9 +119,7 @@ module VagrantPlugins
|
|
116
119
|
command.parameters.each do |key, conf|
|
117
120
|
next if conf[:wrap].nil?
|
118
121
|
|
119
|
-
if conf[:default].nil?
|
120
|
-
next if params[key].nil? || params[key].empty?
|
121
|
-
end
|
122
|
+
next if conf[:default].nil? && (params[key].nil? || params[key].empty?)
|
122
123
|
|
123
124
|
params[key] = conf[:wrap] % params[key]
|
124
125
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
class Registry
|
4
6
|
# Generic registry message printer
|
5
7
|
class Messager
|
6
|
-
I18N_KEY = 'vagrant_devcommands.registry'
|
8
|
+
I18N_KEY = 'vagrant_devcommands.registry'
|
7
9
|
|
8
10
|
def initialize(env)
|
9
11
|
@env = env
|
@@ -20,18 +22,18 @@ module VagrantPlugins
|
|
20
22
|
end
|
21
23
|
|
22
24
|
def def_duplicate(args)
|
23
|
-
@env.ui.warn I18n.t("#{I18N_KEY}.def_duplicate", args)
|
25
|
+
@env.ui.warn I18n.t("#{I18N_KEY}.def_duplicate", **args)
|
24
26
|
@env.ui.warn ''
|
25
27
|
end
|
26
28
|
|
27
29
|
def def_ignored(message, args)
|
28
|
-
@env.ui.warn I18n.t("#{I18N_KEY}.#{message}", args)
|
30
|
+
@env.ui.warn I18n.t("#{I18N_KEY}.#{message}", **args)
|
29
31
|
@env.ui.warn I18n.t("#{I18N_KEY}.def_ignored")
|
30
32
|
@env.ui.warn ''
|
31
33
|
end
|
32
34
|
|
33
35
|
def unknown_options(args)
|
34
|
-
@env.ui.warn I18n.t("#{I18N_KEY}.unknown_options", args)
|
36
|
+
@env.ui.warn I18n.t("#{I18N_KEY}.unknown_options", **args)
|
35
37
|
@env.ui.warn ''
|
36
38
|
end
|
37
39
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
class Registry
|
@@ -21,9 +23,7 @@ module VagrantPlugins
|
|
21
23
|
|
22
24
|
i18n_msg = 'chain_conflict_command'
|
23
25
|
|
24
|
-
if registry.reserved_command?(name)
|
25
|
-
i18n_msg = 'chain_conflict_internal'
|
26
|
-
end
|
26
|
+
i18n_msg = 'chain_conflict_internal' if registry.reserved_command?(name)
|
27
27
|
|
28
28
|
@messager.chain_ignored(i18n_msg, name)
|
29
29
|
|
@@ -41,12 +41,9 @@ module VagrantPlugins
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
# rubocop:disable Metrics/MethodLength
|
45
44
|
def resolve_command_alias_naming_conflicts(registry)
|
46
45
|
registry.command_aliases.each_key do |name|
|
47
|
-
unless registry.valid_command?(name) || registry.valid_chain?(name)
|
48
|
-
next
|
49
|
-
end
|
46
|
+
next unless registry.valid_command?(name) || registry.valid_chain?(name)
|
50
47
|
|
51
48
|
i18n_key = 'command'
|
52
49
|
i18n_key = 'chain' if registry.valid_chain?(name)
|
@@ -59,7 +56,6 @@ module VagrantPlugins
|
|
59
56
|
registry.command_aliases.delete(name)
|
60
57
|
end
|
61
58
|
end
|
62
|
-
# rubocop:enable Metrics/MethodLength
|
63
59
|
end
|
64
60
|
end
|
65
61
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
class Registry
|
@@ -22,7 +24,7 @@ module VagrantPlugins
|
|
22
24
|
next if registry.valid_command?(element[:command])
|
23
25
|
|
24
26
|
@messager.def_ignored('chain_missing_command',
|
25
|
-
chain:
|
27
|
+
chain: chain,
|
26
28
|
command: element)
|
27
29
|
|
28
30
|
registry.chains.delete(chain)
|
@@ -41,7 +43,7 @@ module VagrantPlugins
|
|
41
43
|
|
42
44
|
@messager.def_ignored('command_alias_missing_command',
|
43
45
|
command_alias: command_alias,
|
44
|
-
command:
|
46
|
+
command: cmd)
|
45
47
|
|
46
48
|
registry.command_aliases.delete(command_alias)
|
47
49
|
end
|
@@ -1,12 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
# Registry for definitions from the Commandfile
|
4
6
|
class Registry
|
5
7
|
RESERVED_COMMANDS = %w[completion-data help version].freeze
|
6
8
|
|
7
|
-
attr_accessor :chains
|
8
|
-
attr_accessor :commands
|
9
|
-
attr_accessor :command_aliases
|
9
|
+
attr_accessor :chains, :commands, :command_aliases
|
10
10
|
|
11
11
|
def initialize(env)
|
12
12
|
@env = env
|
@@ -17,8 +17,8 @@ module VagrantPlugins
|
|
17
17
|
@command_aliases = {}
|
18
18
|
|
19
19
|
@duplicates = {
|
20
|
-
'chains'
|
21
|
-
'commands'
|
20
|
+
'chains' => [],
|
21
|
+
'commands' => [],
|
22
22
|
'command_aliases' => []
|
23
23
|
}
|
24
24
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
module Runner
|
@@ -23,8 +25,8 @@ module VagrantPlugins
|
|
23
25
|
@plugin.proxy_with_target_vms(machine, single_target: true) do |vm|
|
24
26
|
env = vm.action(:ssh_run,
|
25
27
|
ssh_run_command: script,
|
26
|
-
ssh_opts:
|
27
|
-
tty:
|
28
|
+
ssh_opts: { extra_args: ['-q'] },
|
29
|
+
tty: command.tty)
|
28
30
|
|
29
31
|
return env[:ssh_run_exit_status] || 0
|
30
32
|
end
|
@@ -67,7 +69,7 @@ module VagrantPlugins
|
|
67
69
|
|
68
70
|
raise I18n.t('vagrant_devcommands.runner.script_error',
|
69
71
|
command: command,
|
70
|
-
error:
|
72
|
+
error: error)
|
71
73
|
end
|
72
74
|
end
|
73
75
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
module Runner
|
@@ -43,7 +45,7 @@ module VagrantPlugins
|
|
43
45
|
@env, @registry
|
44
46
|
),
|
45
47
|
|
46
|
-
'help'
|
48
|
+
'help' => NAMESPACE_CMD::Help.new(@env, @registry),
|
47
49
|
'version' => NAMESPACE_CMD::Version.new(@env)
|
48
50
|
}
|
49
51
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
class Util
|
@@ -73,6 +75,7 @@ module VagrantPlugins
|
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|
78
|
+
# rubocop:disable Metrics/AbcSize
|
76
79
|
# rubocop:disable Metrics/MethodLength
|
77
80
|
def find_common_characters
|
78
81
|
common_chars_of_shorter = Array.new(@shorter.size)
|
@@ -96,6 +99,7 @@ module VagrantPlugins
|
|
96
99
|
|
97
100
|
[common_chars_of_shorter, common_chars_of_longer].map(&:compact)
|
98
101
|
end
|
102
|
+
# rubocop:enable Metrics/AbcSize
|
99
103
|
# rubocop:enable Metrics/MethodLength
|
100
104
|
|
101
105
|
def limited_common_prefix_length
|
@@ -110,7 +114,7 @@ module VagrantPlugins
|
|
110
114
|
|
111
115
|
def matching_index_range(origin)
|
112
116
|
min = origin - matching_window
|
113
|
-
min = 0 if min
|
117
|
+
min = 0 if min.negative?
|
114
118
|
|
115
119
|
max = origin + matching_window
|
116
120
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module DevCommands
|
3
5
|
# Utility module
|
@@ -20,13 +22,13 @@ module VagrantPlugins
|
|
20
22
|
|
21
23
|
def self.collect_mandatory_params(params)
|
22
24
|
params.collect do |key, opts|
|
23
|
-
"--#{key}=<#{key}>" unless opts[:optional]
|
25
|
+
"--#{key}=<#{key}>" unless opts[:optional] || opts[:default]
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
29
|
def self.collect_optional_params(params)
|
28
30
|
params.collect do |key, opts|
|
29
|
-
"[--#{key}=<#{key}>]" if opts[:optional]
|
31
|
+
"[--#{key}=<#{key}>]" if opts[:optional] || opts[:default]
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
data/lib/vagrant/devcommands.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-devcommands
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Neudert
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coveralls
|
@@ -30,44 +30,44 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.10'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.10'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rubocop
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.12.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.12.0
|
69
69
|
description: Vagrant plugin to run commands specified in a Commandfile inside one
|
70
|
-
of your
|
70
|
+
of your Vagrant boxes
|
71
71
|
email:
|
72
72
|
- marc.neudert@gmail.com
|
73
73
|
executables: []
|
@@ -113,7 +113,7 @@ licenses:
|
|
113
113
|
- MIT
|
114
114
|
metadata:
|
115
115
|
allowed_push_host: https://rubygems.org
|
116
|
-
post_install_message:
|
116
|
+
post_install_message:
|
117
117
|
rdoc_options: []
|
118
118
|
require_paths:
|
119
119
|
- lib
|
@@ -121,16 +121,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
121
|
requirements:
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
124
|
+
version: '2.4'
|
125
|
+
- - "<"
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '3.1'
|
125
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
129
|
requirements:
|
127
130
|
- - ">="
|
128
131
|
- !ruby/object:Gem::Version
|
129
|
-
version:
|
132
|
+
version: 1.3.6
|
130
133
|
requirements: []
|
131
|
-
|
132
|
-
|
133
|
-
signing_key:
|
134
|
+
rubygems_version: 3.3.7
|
135
|
+
signing_key:
|
134
136
|
specification_version: 4
|
135
137
|
summary: Runs vagrant commands from a Commandfile
|
136
138
|
test_files: []
|