airbrussh 0.2.1 → 0.3.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 +9 -0
- data/README.md +53 -2
- data/lib/airbrussh/capistrano.rb +0 -2
- data/lib/airbrussh/configuration.rb +18 -1
- data/lib/airbrussh/formatter.rb +41 -5
- data/lib/airbrussh/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cce6c8fd80458eebccd4bc41fd5f55d45435e056
|
4
|
+
data.tar.gz: 1e6c39223361f97a90d2593aec1c3f873c61cc13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1695037c080995aabfe3bca4c05c1066700002803e4909b21fa18c58370e8ce364f3f35d0f624225b2a3a4165aed3410cf6a3bff4f254b26fc70b00f93dbf92f
|
7
|
+
data.tar.gz: d58bd13170ce51ddc74af022e0661d5b1844ede48eab39ac8d289b67832d8b5a84b7e22ee6ba05c56b4fa35eff3df3bf6ec49cf25dc28405a05ab1973fc37b41
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## Next release
|
2
|
+
|
3
|
+
* Your contribution here!
|
4
|
+
|
5
|
+
## 0.3.0 (2015-03-28)
|
6
|
+
|
7
|
+
* New `config.banner` option allows startup message to be disabled or changed (suggestion from [@justindowning](https://github.com/justindowning))
|
8
|
+
* New `config.command_output` option gives full control of whether airbrussh shows or hides the stderr and stdout data received from remote commands; see the usage section of the README for further explanation (suggestion from [@carlesso](https://github.com/carlesso))
|
9
|
+
|
1
10
|
## 0.2.1 (2015-03-02)
|
2
11
|
|
3
12
|
* Un-pin SSHKit dependency now that SSHKit 1.7.1 has been released.
|
data/README.md
CHANGED
@@ -9,6 +9,16 @@ And don't worry: airbrussh saves Capistrano's default verbose output to a separa
|
|
9
9
|
|
10
10
|

|
11
11
|
|
12
|
+
For more details on how exactly Airbrussh changes Capistrano's output and the reasoning behind it, check out the blog post: [Introducing Airbrussh](https://mattbrictson.com/airbrussh).
|
13
|
+
|
14
|
+
## Requirements
|
15
|
+
|
16
|
+
**To use Airbrussh with Capistrano, you will need Capistrano 3.** Capistrano 2.x is not supported.
|
17
|
+
|
18
|
+
Airbrussh has been tested with MRI 2.2, Capistrano 3.4.0, and SSHKit 1.7.1. Other recent version combinations will probably work; [open an issue on GitHub](https://github.com/mattbrictson/airbrussh/issues/new) if you run into trouble.
|
19
|
+
|
20
|
+
Airbrussh's only dependency is SSHKit >= 1.6.1.
|
21
|
+
|
12
22
|
## Installation
|
13
23
|
|
14
24
|
Add this line to your application's Gemfile:
|
@@ -43,31 +53,70 @@ Airbrussh automatically replaces the default Capistrano log formatter, so there
|
|
43
53
|
```ruby
|
44
54
|
Airbrussh.configure do |config|
|
45
55
|
# Capistrano's default, un-airbrusshed output is saved to a file to
|
46
|
-
# facilitate debugging.
|
56
|
+
# facilitate debugging.
|
57
|
+
#
|
58
|
+
# To disable this entirely:
|
47
59
|
# config.log_file = nil
|
60
|
+
#
|
48
61
|
# Default:
|
49
62
|
config.log_file = "log/capistrano.log"
|
50
63
|
|
51
64
|
# Airbrussh patches Rake so it can access the name of the currently executing
|
52
65
|
# task. Set this to false if monkey patching is causing issues.
|
66
|
+
#
|
53
67
|
# Default:
|
54
68
|
config.monkey_patch_rake = true
|
55
69
|
|
56
70
|
# Ansi colors will be used in the output automatically based on whether the
|
57
71
|
# output is a TTY, or if the SSHKIT_COLOR environment variable is set.
|
72
|
+
#
|
58
73
|
# To disable color always:
|
59
74
|
# config.color = false
|
75
|
+
#
|
60
76
|
# Default:
|
61
77
|
config.color = :auto
|
62
78
|
|
63
79
|
# Output is automatically truncated to the width of the terminal window, if
|
64
80
|
# possible. If the width of the terminal can't be determined, no truncation
|
65
|
-
# is performed.
|
81
|
+
# is performed.
|
82
|
+
#
|
83
|
+
# To truncate to a fixed width:
|
66
84
|
# config.truncate = 80
|
85
|
+
#
|
67
86
|
# Or to disable truncation entirely:
|
68
87
|
# config.truncate = false
|
88
|
+
#
|
69
89
|
# Default:
|
70
90
|
config.truncate = :auto
|
91
|
+
|
92
|
+
# If a log_file is configured, airbrussh will output a message at startup
|
93
|
+
# displaying the log_file location.
|
94
|
+
#
|
95
|
+
# To always disable this message:
|
96
|
+
# config.banner = false
|
97
|
+
#
|
98
|
+
# To display an alternative message:
|
99
|
+
# config.banner = "Hello, world!"
|
100
|
+
#
|
101
|
+
# Default:
|
102
|
+
config.banner = :auto
|
103
|
+
|
104
|
+
# You can control whether airbrussh shows the output of SSH commands. For
|
105
|
+
# brevity, the output is hidden by default.
|
106
|
+
#
|
107
|
+
# Display stdout of SSH commands. Stderr is not displayed.
|
108
|
+
# config.command_output = :stdout
|
109
|
+
#
|
110
|
+
# Display stderr of SSH commands. Stdout is not displayed.
|
111
|
+
# config.command_output = :stderr
|
112
|
+
#
|
113
|
+
# Display all SSH command output.
|
114
|
+
# config.command_output = [:stdout, :stderr]
|
115
|
+
# or
|
116
|
+
# config.command_output = true
|
117
|
+
#
|
118
|
+
# Default (all output suppressed):
|
119
|
+
config.command_output = false
|
71
120
|
end
|
72
121
|
```
|
73
122
|
|
@@ -88,6 +137,8 @@ Airbrussh.configure do |config|
|
|
88
137
|
config.monkey_patch_rake = false
|
89
138
|
config.color = :auto
|
90
139
|
config.truncate = :auto
|
140
|
+
config.banner = :auto
|
141
|
+
config.command_output = false
|
91
142
|
end
|
92
143
|
```
|
93
144
|
|
data/lib/airbrussh/capistrano.rb
CHANGED
@@ -1,12 +1,29 @@
|
|
1
1
|
module Airbrussh
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :log_file, :monkey_patch_rake, :color, :truncate
|
3
|
+
attr_accessor :log_file, :monkey_patch_rake, :color, :truncate, :banner,
|
4
|
+
:command_output
|
4
5
|
|
5
6
|
def initialize
|
6
7
|
self.log_file = nil
|
7
8
|
self.monkey_patch_rake = false
|
8
9
|
self.color = :auto
|
9
10
|
self.truncate = :auto
|
11
|
+
self.banner = :auto
|
12
|
+
self.command_output = false
|
13
|
+
end
|
14
|
+
|
15
|
+
def command_output_stdout?
|
16
|
+
command_output_include?(:stdout)
|
17
|
+
end
|
18
|
+
|
19
|
+
def command_output_stderr?
|
20
|
+
command_output_include?(:stderr)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def command_output_include?(sym)
|
26
|
+
command_output == true || Array(command_output).include?(sym)
|
10
27
|
end
|
11
28
|
end
|
12
29
|
end
|
data/lib/airbrussh/formatter.rb
CHANGED
@@ -33,7 +33,7 @@ module Airbrussh
|
|
33
33
|
|
34
34
|
@tasks = {}
|
35
35
|
|
36
|
-
@log_file =
|
36
|
+
@log_file = config.log_file
|
37
37
|
@log_file_formatter = create_log_file_formatter
|
38
38
|
|
39
39
|
@console = Airbrussh::Console.new(original_output)
|
@@ -53,9 +53,14 @@ module Airbrussh
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def write_banner
|
56
|
-
return
|
57
|
-
|
58
|
-
|
56
|
+
return unless config.banner
|
57
|
+
if config.banner == :auto
|
58
|
+
return if @log_file.nil?
|
59
|
+
print_line "Using airbrussh format."
|
60
|
+
print_line "Verbose output is being written to #{blue(@log_file)}."
|
61
|
+
else
|
62
|
+
print_line config.banner
|
63
|
+
end
|
59
64
|
end
|
60
65
|
|
61
66
|
def write_log_file_delimiter
|
@@ -72,7 +77,9 @@ module Airbrussh
|
|
72
77
|
end
|
73
78
|
|
74
79
|
def write(obj)
|
75
|
-
|
80
|
+
# SSHKit's :pretty formatter mutates the stdout and stderr data in the
|
81
|
+
# command obj. So we need to dup it to ensure our copy is unscathed.
|
82
|
+
@log_file_formatter << obj.dup
|
76
83
|
|
77
84
|
case obj
|
78
85
|
when SSHKit::Command then write_command(obj)
|
@@ -114,12 +121,37 @@ module Airbrussh
|
|
114
121
|
print_line " #{number} #{description}"
|
115
122
|
end
|
116
123
|
|
124
|
+
write_command_output(command, number)
|
125
|
+
|
117
126
|
if command.finished?
|
118
127
|
status = format_command_completion_status(command, number)
|
119
128
|
print_line " #{status}"
|
120
129
|
end
|
121
130
|
end
|
122
131
|
|
132
|
+
# Prints the data from the stdout and stderr streams of the given command,
|
133
|
+
# but only if enabled (see Airbrussh::Configuration#command_output).
|
134
|
+
def write_command_output(command, number)
|
135
|
+
# Use a bit of meta-programming here, since stderr and stdout logic
|
136
|
+
# are identical except for different method names.
|
137
|
+
%w(stderr stdout).each do |stream|
|
138
|
+
|
139
|
+
next unless config.public_send("command_output_#{stream}?")
|
140
|
+
output = command.public_send(stream)
|
141
|
+
next if output.empty?
|
142
|
+
|
143
|
+
output.lines.each do |line|
|
144
|
+
print_line " #{number} #{line.chomp}"
|
145
|
+
end
|
146
|
+
|
147
|
+
# The stderr/stdout data provided by the command object is the current
|
148
|
+
# "chunk" as received over the wire. Since there may be more chunks
|
149
|
+
# appended and we don't want to print duplicates, clear the current
|
150
|
+
# data.
|
151
|
+
command.public_send("#{stream}=", "")
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
123
155
|
def print_task_if_changed
|
124
156
|
status = current_task_status
|
125
157
|
|
@@ -197,5 +229,9 @@ module Airbrussh
|
|
197
229
|
string.to_s.colorize(color.to_sym)
|
198
230
|
end
|
199
231
|
end
|
232
|
+
|
233
|
+
def config
|
234
|
+
Airbrussh.configuration
|
235
|
+
end
|
200
236
|
end
|
201
237
|
end
|
data/lib/airbrussh/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airbrussh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Brictson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sshkit
|