vagrant-shell-commander 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/Gemfile.lock +1 -1
- data/README.md +11 -6
- data/lib/vagrant-shell-commander/command.rb +4 -3
- data/lib/vagrant-shell-commander/option_manager.rb +4 -4
- data/lib/vagrant-shell-commander/version.rb +1 -1
- data/spec/command_spec.rb +17 -3
- data/spec/option_manager_spec.rb +5 -5
- data/vagrant-shell-commander.gemspec +1 -1
- metadata +5 -5
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -7,7 +7,7 @@ Vagrant plugin for executing arbitrary shell commands on guest. Executes the giv
|
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
10
|
-
|
10
|
+
As usual with vagrant plugins:
|
11
11
|
|
12
12
|
$ vagrant plugin install vagrant-shell-commander
|
13
13
|
|
@@ -21,14 +21,19 @@ Restrict the machine to run:
|
|
21
21
|
|
22
22
|
$ vagrant sh --cmd 'free' machine1
|
23
23
|
|
24
|
-
|
24
|
+
Specify the working directory:
|
25
25
|
|
26
|
-
$ vagrant sh --cmd 'ls -al' --
|
26
|
+
$ vagrant sh --cmd 'ls -al' --dir '/srv/www'
|
27
|
+
|
28
|
+
Get help:
|
29
|
+
|
30
|
+
$ vagrant sh -h
|
27
31
|
|
28
32
|
## Contributing
|
29
33
|
|
30
34
|
1. Fork it
|
31
35
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
-
3.
|
33
|
-
4.
|
34
|
-
5.
|
36
|
+
3. Add and implement your specs
|
37
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
6. Create new Pull Request
|
@@ -11,10 +11,11 @@ module VagrantShellCommander
|
|
11
11
|
|
12
12
|
return unless argv
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
unless [nil, ''].include? cli_options[:values][:cmd]
|
15
|
+
with_target_vms(argv) do |machine|
|
16
|
+
manage_machine(machine, cli_options)
|
17
|
+
end
|
16
18
|
end
|
17
|
-
|
18
19
|
0
|
19
20
|
end
|
20
21
|
|
@@ -9,13 +9,13 @@ module VagrantShellCommander
|
|
9
9
|
def execute
|
10
10
|
options = {}
|
11
11
|
block = lambda do |parser|
|
12
|
-
parser.banner = "Usage: vagrant sh --cmd 'COMMAND' --
|
12
|
+
parser.banner = "Usage: vagrant sh --cmd 'COMMAND' --dir [DIR] [MACHINE]"
|
13
13
|
|
14
14
|
parser.separator ''
|
15
15
|
|
16
|
-
parser.on('--
|
17
|
-
'Directory to execute the command') do |
|
18
|
-
options[:
|
16
|
+
parser.on('--dir [DIR]', '--change-working-dir [DIR]',
|
17
|
+
'Directory to execute the command') do |dir|
|
18
|
+
options[:dir] = dir
|
19
19
|
end
|
20
20
|
|
21
21
|
parser.on("--cmd 'COMMAND'", "--command 'COMMAND'",
|
data/spec/command_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe VagrantShellCommander::Command do
|
4
4
|
let(:subject) {described_class.new('2', 'command')}
|
5
5
|
let(:argv) {double}
|
6
|
-
let(:opts) {{parser: 'parser', values: '
|
6
|
+
let(:opts) {{parser: 'parser', values: {cmd: 'cmd'}}}
|
7
7
|
|
8
8
|
before(:each) do
|
9
9
|
VagrantShellCommander::OptionManager.stub_chain(:new, :execute).
|
@@ -67,6 +67,7 @@ describe VagrantShellCommander::Command do
|
|
67
67
|
|
68
68
|
context 'running machine' do
|
69
69
|
let(:cmd) {'command'}
|
70
|
+
let(:cwd) {'cwd'}
|
70
71
|
let(:communicate) {double(execute: true)}
|
71
72
|
|
72
73
|
before(:each) do
|
@@ -90,14 +91,27 @@ describe VagrantShellCommander::Command do
|
|
90
91
|
end
|
91
92
|
|
92
93
|
it 'executes the command in the given cwd' do
|
93
|
-
cwd = 'cwd'
|
94
|
-
|
95
94
|
VagrantShellCommander::OptionManager.stub_chain(:new, :execute).
|
96
95
|
and_return(parser: 'parser', values: {cmd: cmd, cwd: cwd})
|
97
96
|
|
98
97
|
communicate.should_receive(:execute).with("cd #{cwd} && #{cmd}")
|
99
98
|
end
|
100
99
|
|
100
|
+
describe 'does nothing' do
|
101
|
+
after(:each) do
|
102
|
+
subject.should_not_receive(:with_target_vms)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'an empty command' do
|
106
|
+
VagrantShellCommander::OptionManager.stub_chain(:new, :execute).
|
107
|
+
and_return(parser: 'parser', values: {cmd: '', cwd: cwd})
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'non present command' do
|
111
|
+
VagrantShellCommander::OptionManager.stub_chain(:new, :execute).
|
112
|
+
and_return(parser: 'parser', values: {cwd: cwd})
|
113
|
+
end
|
114
|
+
end
|
101
115
|
end
|
102
116
|
end
|
103
117
|
end
|
data/spec/option_manager_spec.rb
CHANGED
@@ -26,17 +26,17 @@ describe VagrantShellCommander::OptionManager do
|
|
26
26
|
subject.execute
|
27
27
|
end
|
28
28
|
|
29
|
-
it 'has a
|
30
|
-
|
29
|
+
it 'has a dir option' do
|
30
|
+
dir_value = 'dir'
|
31
31
|
|
32
|
-
option_parser.stub(:on).with('--
|
32
|
+
option_parser.stub(:on).with('--dir [DIR]',
|
33
33
|
anything,
|
34
34
|
anything).
|
35
|
-
and_yield(
|
35
|
+
and_yield(dir_value)
|
36
36
|
|
37
37
|
result = subject.execute
|
38
38
|
|
39
|
-
expect(result[:values][:
|
39
|
+
expect(result[:values][:dir]).to eql(dir_value)
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'has a cmd option' do
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = VagrantShellCommander::VERSION
|
9
9
|
spec.authors = ["Federico Gimenez Nieto"]
|
10
10
|
spec.email = ["federico.gimenez@gmail.com"]
|
11
|
-
spec.description = %q{This plugin allows you to execute a given shell command on all the machines of your multinode environment. You can
|
11
|
+
spec.description = %q{This Vagrant plugin allows you to execute a given shell command on all the machines of your multinode environment. You can also specify the working directory to execute the command}
|
12
12
|
spec.summary = %q{Vagrant plugin for executing arbitrary shell commands on guest(s)}
|
13
13
|
spec.homepage = "https://github.com/fgimenez/vagrant-shell-commander"
|
14
14
|
spec.license = "MIT"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-shell-commander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -123,9 +123,9 @@ dependencies:
|
|
123
123
|
- - ! '>='
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
|
-
description: This plugin allows you to execute a given shell command on all
|
127
|
-
of your multinode environment. You can
|
128
|
-
the command
|
126
|
+
description: This Vagrant plugin allows you to execute a given shell command on all
|
127
|
+
the machines of your multinode environment. You can also specify the working directory
|
128
|
+
to execute the command
|
129
129
|
email:
|
130
130
|
- federico.gimenez@gmail.com
|
131
131
|
executables: []
|