jossh 0.0.3 → 0.1.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/README.md +14 -7
- data/bin/jossh +44 -14
- data/lib/jossh/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: 065f5d98494010a3bc73bafd4317937e34aab7af
|
4
|
+
data.tar.gz: a293c204f348966006ae2d366d6f27ea9fa8a377
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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>
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
-
|
12
|
-
" <host>
|
13
|
-
"
|
14
|
-
"
|
15
|
-
"
|
16
|
-
"
|
17
|
-
"
|
18
|
-
"
|
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
|
-
|
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
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
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
|
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-
|
11
|
+
date: 2015-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|