bard 0.66.0 → 0.68.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bard/config.rb +11 -0
- data/lib/bard/remote_command.rb +23 -0
- data/lib/bard/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d6ffeb50c8bcafe4462e42e462d34c81a1d44690c38cef2b44682e11fed4854
|
4
|
+
data.tar.gz: 602a01d2fd94765904b0f767945149e8984d84856b2598f8a44afceda82ac62b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5c40d167fe14e473dd56a3e14ccebe922068dcff113783b7074df31de8de100da799c10470a00779fc257cd85efa99568f8accf988886cafc7e0606f8423e6a
|
7
|
+
data.tar.gz: 97fa25538c174668498f4a38de33b9cc17e4d60304675256a4a130d50920bfd814fc77aa48c76b88dda2d2dbe44648323cdc45736debe4b184201b3bf82e2a55
|
data/lib/bard/config.rb
CHANGED
@@ -61,6 +61,17 @@ module Bard
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
+
def backup *args
|
65
|
+
if args.length == 1
|
66
|
+
@backup = args.first
|
67
|
+
elsif args.length == 0
|
68
|
+
return @backup if defined?(@backup)
|
69
|
+
@backup = true
|
70
|
+
else
|
71
|
+
raise ArgumentError
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
64
75
|
private
|
65
76
|
|
66
77
|
class Server < Struct.new(:project_name, :key, :ssh, :path, :ping, :gateway, :ssh_key, :env)
|
data/lib/bard/remote_command.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
module Bard
|
2
2
|
class RemoteCommand < Struct.new(:server, :command, :home)
|
3
|
+
def self.run! *args
|
4
|
+
new(*args).run!
|
5
|
+
end
|
6
|
+
|
3
7
|
def local_command
|
4
8
|
uri = URI.parse("ssh://#{server.ssh}")
|
5
9
|
ssh_key = server.ssh_key ? "-i #{server.ssh_key} " : ""
|
@@ -17,6 +21,25 @@ module Bard
|
|
17
21
|
end
|
18
22
|
cmd
|
19
23
|
end
|
24
|
+
|
25
|
+
def run! verbose: false
|
26
|
+
failed = false
|
27
|
+
|
28
|
+
if verbose
|
29
|
+
failed = !(system local_command)
|
30
|
+
else
|
31
|
+
stdout, stderr, status = Open3.capture3(local_command)
|
32
|
+
failed = status.to_i.nonzero?
|
33
|
+
if failed
|
34
|
+
$stdout.puts stdout
|
35
|
+
$stderr.puts stderr
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
if failed
|
40
|
+
raise "Running command failed: #{local_command}"
|
41
|
+
end
|
42
|
+
end
|
20
43
|
end
|
21
44
|
end
|
22
45
|
|
data/lib/bard/version.rb
CHANGED