jossh 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -7
  3. data/bin/jossh +44 -14
  4. data/lib/jossh/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e21292d5cf9f6a4a812cb4b32950e56516b17ca5
4
- data.tar.gz: 00c4ebc56ab4240f035ced04b1ccbd4917ad0a1d
3
+ metadata.gz: 065f5d98494010a3bc73bafd4317937e34aab7af
4
+ data.tar.gz: a293c204f348966006ae2d366d6f27ea9fa8a377
5
5
  SHA512:
6
- metadata.gz: 3415b4accc2faf4d0bcadb7de6c570fadbd3e52376bcb8e14e30dc72b8200836576c0e846334ba2acdc52990e3d87cb656a76e9029a0ed7353c32788c1a367f8
7
- data.tar.gz: 4a3e0f6b97c859f070d0840f7b62e3348b2d3b7fb000ad372a32a7ee6a142a48149a97fcc80fcfe054a62171c665776f280f343771e8294df6511993d6c76e89
6
+ metadata.gz: bee1fe6fa0b70d08cd4624d7e162dc27a1107c0559ef3290da3bfb41e97a5edd6197ffbc2b2706ccdc18baf7c6367acf5f6e4a7ee9099293e4a979100f6ae43f
7
+ data.tar.gz: 01505c2b98995e22f7bb0234c3708516476d7e7f40b374d79e02ba5adae68107d15d44f720346fe12b32b50814c24a4fa4f243221d5e39144ab9cea8708a720d
data/README.md CHANGED
@@ -43,15 +43,22 @@ commands or a local script over SSH.
43
43
  $ jossh
44
44
 
45
45
  Usage: jossh <host> <script>
46
+ jossh -h
46
47
 
47
- <host> - any key available in ./ssh_hosts.yml
48
- <script> - can be either a filename or one or more direct command
49
- quotes are only needed if you include multiple commands
50
- with && or semicolor (;)
48
+ <host> can be:
49
+ - :symbol - in this case we will look in ./ssh_hosts.yml
50
+ - host - in this case we will use the current logged in user
51
+ - user@host
52
+
53
+ <script> can be:
54
+ - a filename
55
+ - one or more direct command - quotes are only needed if you include
56
+ multiple commands with && or semicolor (;)
57
+
58
+ Examples: jossh :production git status
59
+ jossh jack@server.com "cd ~ && ls -l"
60
+ jossh server.com deploy
51
61
 
52
- Examples: jossh production git status
53
- jossh stage "cd ~ && ls -l"
54
- jossh devhost deploy
55
62
  ```
56
63
 
57
64
  ## Library Usage
data/bin/jossh CHANGED
@@ -1,32 +1,62 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'jossh'
4
+ require 'etc'
4
5
 
5
6
  # for dev (not needed in most cases)
6
7
  # require File.dirname(__FILE__) + "/../lib/jossh"
7
8
 
8
9
  trap(:INT) { abort "\r\nGoodbye" }
9
10
 
11
+ def short_usage
12
+ "\nUsage: jossh <host> <script>\n" +
13
+ " jossh -h\n\n"
14
+ end
15
+
10
16
  def usage
11
- "\nUsage: jossh <host> <script>\n\n" +
12
- " <host> - any key available in ./ssh_hosts.yml\n" +
13
- " <script> - can be either a filename or one or more direct command\n" +
14
- " quotes are only needed if you include multiple commands\n" +
15
- " with && or semicolor (;)\n\n" +
16
- "Examples: jossh production git status\n" +
17
- " jossh stage \"cd ~ && ls -l\"\n" +
18
- " jossh devhost deploy"
17
+ short_usage +
18
+ " <host> can be:\n"+
19
+ " - :symbol - in this case we will look in ./ssh_hosts.yml\n" +
20
+ " - host - in this case we will use the current logged in user\n" +
21
+ " - user@host\n\n" +
22
+ " <script> can be:\n" +
23
+ " - a filename\n" +
24
+ " - one or more direct command - quotes are only needed if you include\n" +
25
+ " multiple commands with && or semicolor (;)\n\n" +
26
+ "Examples: jossh :production git status\n" +
27
+ " jossh jack@server.com \"cd ~ && ls -l\"\n" +
28
+ " jossh server.com deploy"
19
29
  end
20
30
 
21
31
  def run
22
- host = ARGV.shift
32
+ ARGV.empty? and abort short_usage
33
+ ARGV[0] == '-h' and abort usage
34
+ host = ARGV.shift.dup
23
35
  script = ARGV.join ' '
24
- host and script or abort usage
25
- if File.exist? script
26
- ssh_script! host.to_sym, script
27
- else
28
- ssh host.to_sym, script
36
+ host and script or abort short_usage
37
+ host = standardize_host host
38
+ begin
39
+ if File.exist? script
40
+ ssh_script! host, script
41
+ else
42
+ ssh host, script
43
+ end
44
+ rescue => e
45
+ abort e.message
46
+ end
47
+ end
48
+
49
+ def standardize_host(str)
50
+ if str[0] == ':'
51
+ str[0] = ''
52
+ return str.to_sym
53
+ end
54
+
55
+ if str =~ /^(.+)@(.+)$/
56
+ return { user: $1, host: $2 }
29
57
  end
58
+
59
+ return { user: Etc.getlogin, host: str }
30
60
  end
31
61
 
32
62
  run
data/lib/jossh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jossh
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jossh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-26 00:00:00.000000000 Z
11
+ date: 2015-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole