kommando 0.0.9 → 0.0.10
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 +6 -0
- data/examples/env.rb +12 -0
- data/lib/kommando/version.rb +1 -1
- data/lib/kommando.rb +34 -3
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da77c3f809cd0a9d9fdf6ae89c929d6e1ab457f9
|
4
|
+
data.tar.gz: 2e4815740c38be873a97f4f64d278489e18232f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5ab9ed6a24dd357a3fd86e104723034da942147d7e203f44634fdab52736c2dd59d319cb3432a9742721b975ca79abbc6d1c4c840f86547d95e7021835ce433
|
7
|
+
data.tar.gz: 8e83c297b5706403481eebab8c02a30afff4e7bced1b506ce0733c68c6d4f167584da75ca1e34cb16882ea93940526d3203d2005c8f738645a62729b64057cbf
|
data/CHANGELOG.md
CHANGED
data/examples/env.rb
ADDED
data/lib/kommando/version.rb
CHANGED
data/lib/kommando.rb
CHANGED
@@ -24,6 +24,8 @@ class Kommando
|
|
24
24
|
@timeout_happened = false
|
25
25
|
@kill_happened = false
|
26
26
|
|
27
|
+
@env = opts[:env] || {}
|
28
|
+
|
27
29
|
@code = nil
|
28
30
|
@executed = false
|
29
31
|
|
@@ -52,16 +54,45 @@ class Kommando
|
|
52
54
|
|
53
55
|
command, *args = if @cmd.start_with? "$"
|
54
56
|
@shell = true
|
55
|
-
trash, line = @cmd.split "$"
|
57
|
+
trash, line = @cmd.split "$", 2
|
56
58
|
line.lstrip!
|
57
59
|
["bash", "-c", line]
|
58
60
|
else
|
59
|
-
#command, *args = @cmd.split " "
|
60
61
|
@cmd.split " "
|
61
62
|
end
|
62
63
|
|
64
|
+
@env.each_pair do |k,v|
|
65
|
+
ENV[k.to_s] = v
|
66
|
+
end
|
67
|
+
|
68
|
+
interpolated_args = []
|
69
|
+
if @shell
|
70
|
+
interpolated_args << args.shift
|
71
|
+
shell_line = args[0]
|
72
|
+
|
73
|
+
to_be_interpolated = shell_line.scan(/\$[^\s]*/)
|
74
|
+
to_be_interpolated.each do |to_interpolate|
|
75
|
+
if ENV[to_interpolate]
|
76
|
+
shell_line.gsub!("${to_interpolate}", ENV[to_interpolate])
|
77
|
+
else
|
78
|
+
shell_line.gsub!("${to_interpolate}", "")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
interpolated_args << shell_line
|
83
|
+
else
|
84
|
+
args.each do |arg|
|
85
|
+
interpolated_args << if arg.start_with? "$"
|
86
|
+
env_name = arg.split("$")[1]
|
87
|
+
ENV[env_name]
|
88
|
+
else
|
89
|
+
arg
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
63
94
|
begin
|
64
|
-
PTY.spawn(command, *
|
95
|
+
PTY.spawn(command, *interpolated_args) do |stdout, stdin, pid|
|
65
96
|
if @retry && stdout.eof?
|
66
97
|
@executed = false
|
67
98
|
return run
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kommando
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matti Paksula
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- bin/stress
|
106
106
|
- bin/version
|
107
107
|
- examples/async.rb
|
108
|
+
- examples/env.rb
|
108
109
|
- examples/exit.rb
|
109
110
|
- examples/kill.rb
|
110
111
|
- examples/live_output.rb
|