xlogin 0.16.4 → 0.16.5
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/lib/xlogin/cli.rb +10 -12
- data/lib/xlogin/rake_task.rb +10 -12
- data/lib/xlogin/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ef44033bfbc542654526a3a009b4400b813b3919beeac902aa38b4a68937ed6
|
4
|
+
data.tar.gz: 5d71ff7e0f4acd38e0370fec946ed13165615bfc4d955047fb29a8f63296cef9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47d8c407ed8167173641c237eb07a0874d995b53b96191104961a29628b0514caa5bfc5b1c547afceba3bbf388fd31c64ae301e7e7dd4068ee744ed3825c3fb8
|
7
|
+
data.tar.gz: 7a42ce312379c15c7faf1845dbd76dc29c9c1b407bfcdd684ba9563d259f201ef06a3feadab90139c490ca2bdf952efcbd4695cd302b5e8bfb577dba19cbc8e9
|
data/lib/xlogin/cli.rb
CHANGED
@@ -42,7 +42,7 @@ module Xlogin
|
|
42
42
|
loggers << ((jobs > 1)? buffer : $stdout)
|
43
43
|
loggers << File.expand_path(File.join(config[:logdir], "#{info[:name]}.log"), ENV['PWD']) if config[:logdir]
|
44
44
|
|
45
|
-
session = Xlogin.get(info.merge(log: loggers))
|
45
|
+
session = Xlogin.get(info.merge(log: loggers, **config[:env]))
|
46
46
|
session.enable(session.config.enable) if session.config.enable && Xlogin.settings.enable?
|
47
47
|
|
48
48
|
command_lines = config[:command].flat_map { |e| e.to_s.split(';').map(&:strip) }
|
@@ -60,7 +60,7 @@ module Xlogin
|
|
60
60
|
|
61
61
|
def run(args)
|
62
62
|
config = Hash.new
|
63
|
-
config[:env] =
|
63
|
+
config[:env] = {}
|
64
64
|
config[:inventory] = []
|
65
65
|
config[:template] = []
|
66
66
|
config[:command] = []
|
@@ -70,23 +70,21 @@ module Xlogin
|
|
70
70
|
parser.banner = "#{File.basename($0)} HOST_PATTERN [Options]"
|
71
71
|
parser.version = Xlogin::VERSION
|
72
72
|
|
73
|
-
parser.on('-i PATH', '--inventory', String,
|
74
|
-
parser.on('-t PATH', '--template', String,
|
75
|
-
parser.on('-L PATH', '--log-dir', String,
|
76
|
-
|
77
|
-
parser.on('
|
73
|
+
parser.on('-i PATH', '--inventory', String, 'The PATH to the inventory file.') { |v| config[:inventory] << v }
|
74
|
+
parser.on('-t PATH', '--template', String, 'The PATH to the template file or directory.'){ |v| config[:template] << v }
|
75
|
+
parser.on('-L PATH', '--log-dir', String, 'The PATH to the log directory.') { |v| config[:logdir] = v }
|
76
|
+
parser.on('-j NUM', '--jobs', Integer, 'The NUM of jobs to execute in parallel.') { |v| config[:jobs] = v }
|
77
|
+
parser.on( '--enable', TrueClass, 'Automatically enable privilege mode.') { |v| config[:enable] = v }
|
78
|
+
parser.on('-l', '--list', TrueClass, 'List the inventory.') { |v| config[:runner] = self.method(:list) }
|
78
79
|
parser.on('-e COMMAND', '--exec', String, 'Execute commands and quit.'){ |v| config[:runner] = self.method(:exec); config[:command] << v }
|
79
|
-
|
80
|
-
parser.on('-E KEY=VAL', '--env', /(\w+=\w+)+/, 'Environment variables.') { |v| config[:env] << v }
|
81
|
-
parser.on('-j NUM', '--jobs', Integer, 'The NUM of jobs to execute in parallel.'){ |v| config[:jobs] = v }
|
80
|
+
parser.on('-E KEY=VAL', '--env', /\w+=[^=]+/, 'Environment variables.') { |v| v.split('=').tap{ |k, v| config[:env].update(k.to_sym => v) } }
|
82
81
|
|
83
82
|
config[:patterns] = parser.parse!(args)
|
84
83
|
config[:inventory] << DEFAULT_INVENTORY if config[:inventory].empty?
|
85
84
|
config[:template] << DEFAULT_TEMPLATE if config[:template].empty?
|
86
85
|
|
87
86
|
Xlogin.configure do
|
88
|
-
set
|
89
|
-
|
87
|
+
set enable: config[:enable]
|
90
88
|
source *config[:inventory].map{ |e| File.expand_path(e, ENV['PWD']) }
|
91
89
|
template *config[:template].map { |e| File.expand_path(e, ENV['PWD']) }
|
92
90
|
end
|
data/lib/xlogin/rake_task.rb
CHANGED
@@ -100,27 +100,25 @@ module Xlogin
|
|
100
100
|
RakeTask.shutdown! if fail_on_error
|
101
101
|
|
102
102
|
session.log_message(e.to_s.colorize(color: :red)) if session
|
103
|
-
print(buffer.string + "\n"
|
103
|
+
print(buffer.string.colorize(color: :red) + "\n") if Rake.application.options.always_multitask
|
104
104
|
return false
|
105
105
|
ensure
|
106
106
|
session.close rescue nil
|
107
107
|
end
|
108
108
|
|
109
|
-
def puts(text
|
110
|
-
|
111
|
-
|
112
|
-
text = text.to_s
|
113
|
-
text = text + "\n" unless text[-1] == "\n"
|
114
|
-
print(text, **opts)
|
109
|
+
def puts(text)
|
110
|
+
strio = StringIO.new.tap{ |io| io.puts text }
|
111
|
+
print(strio.string)
|
115
112
|
end
|
116
113
|
|
117
|
-
def print(text
|
118
|
-
text = text.to_s
|
114
|
+
def print(text)
|
115
|
+
text = text.to_s.gsub("\r", '')
|
119
116
|
return if text.empty?
|
120
117
|
|
121
|
-
|
122
|
-
|
123
|
-
|
118
|
+
if Rake.application.options.always_multitask
|
119
|
+
strio = StringIO.new.tap{ |io| io.puts text.lines.map{ |line| "#{name}\t|#{line}" } }
|
120
|
+
text = strio.string
|
121
|
+
end
|
124
122
|
$stdout.print(text)
|
125
123
|
end
|
126
124
|
|
data/lib/xlogin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xlogin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.16.
|
4
|
+
version: 0.16.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- haccht
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-telnet
|