hotdog 0.10.0 → 0.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd779ac66dbd9c74001c9be43cfc2fa0e9cf8a5b
4
- data.tar.gz: 3e7b187c2adcf00368c470abda57c194354631a0
3
+ metadata.gz: 52dcd14a86fb66237bcb18755f02fde4109a2c22
4
+ data.tar.gz: dcca4b54617bfb3dac88bff53db1605f26535984
5
5
  SHA512:
6
- metadata.gz: fe1134ef72ab05bd66e1a97fdf059c64e815203cdeff0b536202a52043c583b62b787f990eb6d1133a20256732a434648a607d479524f9720323439f80b9700e
7
- data.tar.gz: e8510f2f2b0dfa42828392e1f34b1e65fb83feb334030d282c9c1c76199d797de3b8e69df42a94cc08d784e24d3b1f224ce2c6b6813e1d0a3c7d52eae402109a
6
+ metadata.gz: 2b5a34f103669cdca02a4233d1af3cff3c57b827a8b6b97b87bd9c54bb8fd71e411800540655597825cc3ba23e5753c49e0f0bc465f1354ddf047fa7b1e86c23
7
+ data.tar.gz: 4b1d29a2ce4ddc458dc3a6d6a63d7ceff460bb24139e7083a282edaef3a7d3f08cf36fcd989fb4cc93c8723f9d381a588d60267f0861ed5f1d551689cef7cce3
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "json"
4
+ require "shellwords"
5
+ require "hotdog/commands/ssh"
6
+
7
+ module Hotdog
8
+ module Commands
9
+ class Scp < SingularSshAlike
10
+ private
11
+ def build_command_string(host, command=nil, options={})
12
+ # replace "@:" by actual hostname
13
+ cmdline = ["scp"] + build_command_options(options) + Shellwords.split(command).map { |token| token.gsub(/@(?=:)/, host) }
14
+ Shellwords.join(cmdline)
15
+ end
16
+
17
+ def build_command_options(options={})
18
+ arguments = []
19
+ if options[:forward_agent]
20
+ # nop
21
+ end
22
+ if options[:identity_file]
23
+ arguments << "-i" << options[:identity_file]
24
+ end
25
+ if options[:user]
26
+ arguments << "-o" << "User=#{options[:user]}"
27
+ end
28
+ if options[:options]
29
+ arguments += options[:options].flat_map { |option| ["-o", option] }
30
+ end
31
+ if options[:port]
32
+ arguments << "-P" << options[:port]
33
+ end
34
+ if options[:verbose]
35
+ arguments << "-v"
36
+ end
37
+ arguments
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "json"
4
+ require "shellwords"
5
+ require "hotdog/commands/ssh"
6
+
7
+ module Hotdog
8
+ module Commands
9
+ class Sftp < SingularSshAlike
10
+ private
11
+ def build_command_string(host, command=nil, options={})
12
+ cmdline = ["sftp"] + build_command_options(options) + [host]
13
+ if command
14
+ logger.warn("ignore remote command: #{command}")
15
+ end
16
+ Shellwords.join(cmdline)
17
+ end
18
+
19
+ def build_command_options(options={})
20
+ arguments = []
21
+ if options[:forward_agent]
22
+ # nop
23
+ end
24
+ if options[:identity_file]
25
+ arguments << "-i" << options[:identity_file]
26
+ end
27
+ if options[:user]
28
+ arguments << "-o" << "User=#{options[:user]}"
29
+ end
30
+ if options[:options]
31
+ arguments += options[:options].flat_map { |option| ["-o", option] }
32
+ end
33
+ if options[:port]
34
+ arguments << "-P" << options[:port]
35
+ end
36
+ if options[:verbose]
37
+ arguments << "-v"
38
+ end
39
+ arguments
40
+ end
41
+ end
42
+ end
43
+ end
@@ -186,16 +186,10 @@ module Hotdog
186
186
  end
187
187
  end
188
188
 
189
- class Ssh < SshAlike
189
+ class SingularSshAlike < SshAlike
190
190
  def define_options(optparse, options={})
191
191
  super
192
192
  options[:index] = nil
193
- optparse.on("-D BIND_ADDRESS", "Specifies a local \"dynamic\" application-level port forwarding") do |bind_address|
194
- options[:dynamic_port_forward] = bind_address
195
- end
196
- optparse.on("-L BIND_ADDRESS", "Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side") do |bind_address|
197
- options[:port_forward] = bind_address
198
- end
199
193
  optparse.on("-n", "--index INDEX", "Use this index of host if multiple servers are found", Integer) do |index|
200
194
  options[:index] = index
201
195
  end
@@ -216,7 +210,7 @@ module Hotdog
216
210
  if hosts.length != 1
217
211
  result = hosts.each_with_index.map { |host, i| [i, host] }
218
212
  STDERR.print(format(result, fields: ["index", "host"]))
219
- logger.error("found %d hosts." % result.length)
213
+ logger.error("found %d candidates." % result.length)
220
214
  exit(1)
221
215
  end
222
216
  end
@@ -227,7 +221,20 @@ module Hotdog
227
221
  exec(cmdline)
228
222
  exit(127)
229
223
  end
224
+ end
225
+
226
+ class Ssh < SingularSshAlike
227
+ def define_options(optparse, options={})
228
+ super
229
+ optparse.on("-D BIND_ADDRESS", "Specifies a local \"dynamic\" application-level port forwarding") do |bind_address|
230
+ options[:dynamic_port_forward] = bind_address
231
+ end
232
+ optparse.on("-L BIND_ADDRESS", "Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side") do |bind_address|
233
+ options[:port_forward] = bind_address
234
+ end
235
+ end
230
236
 
237
+ private
231
238
  def build_command_options(options={})
232
239
  arguments = super
233
240
  if options[:dynamic_port_forward]
@@ -1,3 +1,3 @@
1
1
  module Hotdog
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotdog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yamashita Yuu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-21 00:00:00.000000000 Z
11
+ date: 2016-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -175,7 +175,9 @@ files:
175
175
  - lib/hotdog/commands/hosts.rb
176
176
  - lib/hotdog/commands/ls.rb
177
177
  - lib/hotdog/commands/pssh.rb
178
+ - lib/hotdog/commands/scp.rb
178
179
  - lib/hotdog/commands/search.rb
180
+ - lib/hotdog/commands/sftp.rb
179
181
  - lib/hotdog/commands/ssh.rb
180
182
  - lib/hotdog/commands/tags.rb
181
183
  - lib/hotdog/commands/up.rb