koma 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 486c8ce6d46fc55bf3fdf9484867f3ffb68543f8
4
- data.tar.gz: 39da4a369c61e1003ea8beecd9de570dcab16cf8
3
+ metadata.gz: 3ae88014a1a220b9d13805154813b8974523c8b4
4
+ data.tar.gz: 74fd9919c86669ca86eb4b03265f60506d2e0a9b
5
5
  SHA512:
6
- metadata.gz: b4e286aec69d50a45e370932aeef622f567365086f925f380bfd19486d6ffeb4de7626cfb165d9280124180e2f172814afbb4a57197786866de4885aad0418f0
7
- data.tar.gz: 67a8764129db2e91df204d889f5e8851d4a7dfc5c3e5b2ace3e720b36c8685382ee85ee6c07406cefd237d0f53a0e3cf86b9ba171f734c529818f196e19b8264
6
+ metadata.gz: aac147c41110d1676a13ec5529ad5ffb43c11bdc5011fd4ba487a95abd09f33bbb8bdccd6959098a262f17ff4f9f43328a76be1ae13de4f19054df5196de1edd
7
+ data.tar.gz: 7034dba38a96abe98cc9487b48c38ee1ed7585b5de9d5232aa98ec3f927b423bfe73c3cec30cb190e5df5f700c784653c6046acc0085b182f66947f6645ca40b
data/README.md CHANGED
@@ -32,7 +32,7 @@ $ koma ssh example.com
32
32
 
33
33
  And get stdout like [this](stdout_sample.json).
34
34
 
35
- ### Gather multi host
35
+ ### Gather multiple hosts
36
36
 
37
37
  ```sh
38
38
  $ koma ssh example.com,example.jp
@@ -46,6 +46,12 @@ $ koma ssh example.com,example.jp
46
46
  }
47
47
  ```
48
48
 
49
+ ### Pro Tip: Gather multiple hosts with ~/.ssh/config
50
+
51
+ ```sh
52
+ $ cat ~/.ssh/config | koma ssh --key platform,platform_version
53
+ ```
54
+
49
55
  ## Host inventory keys
50
56
 
51
57
  ```sh
@@ -4,7 +4,7 @@ require 'yaml'
4
4
 
5
5
  module Koma
6
6
  class CLI < Thor
7
- desc 'ssh', 'stdout remote host inventory'
7
+ desc 'ssh <host1,host2,..>', 'stdout remote host inventory'
8
8
  option :key,
9
9
  type: :string,
10
10
  banner: '<key1,key2,..>',
@@ -29,7 +29,23 @@ module Koma
29
29
  type: :boolean,
30
30
  desc: "enable #{key}"
31
31
  end
32
- def ssh(host)
32
+ def ssh(host = nil)
33
+ if host.nil?
34
+ begin
35
+ stdin = timeout(5) do
36
+ $stdin.read
37
+ end
38
+ rescue Timeout::Error
39
+ STDERR.puts 'ERROR: "koma ssh" was called with no arguments'
40
+ STDERR.puts 'Usage: "koma ssh <host1,host2,..>"'
41
+ return
42
+ end
43
+ ret = stdin.split("\n").select { |line| line =~ /^Host ([^\s\*]+)/ }.map do |line|
44
+ line =~ /^Host ([^\s]+)/
45
+ Regexp.last_match[1]
46
+ end
47
+ host = ret.join(',')
48
+ end
33
49
  backend = Koma::Backend::Ssh.new(host, options)
34
50
  if options[:yaml]
35
51
  puts YAML.dump(backend.gather)
@@ -70,7 +86,7 @@ module Koma
70
86
  end
71
87
  end
72
88
 
73
- option :version, type: :boolean, aliases: :v
89
+ option :version, type: :boolean, aliases: :V
74
90
  def help(version = nil)
75
91
  if version
76
92
  puts Koma::VERSION
@@ -1,3 +1,3 @@
1
1
  module Koma
2
- VERSION = '0.7.3'
2
+ VERSION = '0.8.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: koma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-18 00:00:00.000000000 Z
11
+ date: 2016-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor