shuttle_cli 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 133346c8ebd092e855e5bb1747aeb5b65d36350c
4
+ data.tar.gz: 149f8dd579dba411ec55a818d5846ca2f78ebe5e
5
+ SHA512:
6
+ metadata.gz: c63008f1a98ba692d7b7d411620effdb41f0be2b6e64cc0fd982fb32efd5f5531ac69b3d28cf05c0f38e14d2f9ea58d4dda1e58b970533ed2b7f02f071112e89
7
+ data.tar.gz: 2d64856f15013e4060c9ddef5c6293ba3faa4d75992d51bdf17e94459577c484da372a76a0bb49d327b9262bc9b187f6150554f99b2861c8cbcea0400848f6b8
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in shuttle.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Hendrik Kleinwaechter
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,48 @@
1
+ # Shuttle Command Line Client
2
+
3
+ [Shuttle](http://fitztrev.github.io/shuttle/) is an incredibly awesome SSH Manager for OS X. It sits in your menu bar. For people who work in the terminal day in/out this port can be of help. It reads your default `shuttle.json` file and offers you A CLI interface. In fact it works without the Shuttle client as well. All you need is a valid `.shuttle.json` file in your homefolder.
4
+
5
+ ```
6
+ $ shuttle
7
+ +--------+---------------------------------------------------------------------+
8
+ | number | name | command |
9
+ +--------+----------------------+-----------------------------------------------+
10
+ | 1 | Zeit.io | ssh foo@zeit.io |
11
+ | 2 | Client X | ssh bar@bar.com |
12
+ | 3 | Trapserver | ssh trap@trap.com |
13
+ +--------+----------------------+-----------------------------------------------+
14
+
15
+ Enter a bookmark number to connect:
16
+ $ 3
17
+
18
+ connecting....
19
+ ```
20
+
21
+
22
+ ## Installation
23
+
24
+ You will need `Ruby 2` installed on your mac. If you don't have it, have a look at [rbenv](https://github.com/sstephenson/rbenv) and [ruby-build](https://github.com/sstephenson/ruby-build)
25
+
26
+ Install it yourself as:
27
+
28
+ $ gem install shuttle
29
+
30
+ Make sure to rehash your environment:
31
+
32
+ $ rbenv rehash
33
+
34
+ If you have shuttle make sure your `~/.shuttle.json` is properly configured. Alternatively you can also just create a blank one without even having the OS X App shuttle. [Get an example here](https://github.com/fitztrev/shuttle/blob/master/tests/.shuttle.json)
35
+
36
+ ## Usage
37
+
38
+ Start shuttle by typing:
39
+
40
+ $ shuttle
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it ( https://github.com/hendricius/shuttle/fork )
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative "../lib/shuttle_cli"
3
+
4
+ module ShuttleCli
5
+ class CLI
6
+ class << self
7
+ def printer
8
+ @printer ||= ShuttleCli::Printer.new
9
+ end
10
+
11
+ def start
12
+ printer.print
13
+ take_user_input
14
+ end
15
+
16
+ def take_user_input
17
+ puts "Enter a bookmark number to connect:"
18
+ number = gets.chomp.to_i
19
+ printer.connect_to_number number
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ ShuttleCli::CLI.start
@@ -0,0 +1,13 @@
1
+ module ShuttleCli
2
+ # Your code goes here...
3
+ end
4
+
5
+ require 'terminal-table'
6
+ require 'json'
7
+ require 'pry'
8
+ require 'active_support/core_ext/hash/indifferent_access'
9
+
10
+ require_relative 'shuttle_cli/version'
11
+ require_relative 'shuttle_cli/printer'
12
+ require_relative 'shuttle_cli/reader'
13
+ require_relative 'shuttle_cli/bookmark'
@@ -0,0 +1,33 @@
1
+ module ShuttleCli
2
+ class Bookmark
3
+ attr_accessor :children, :name, :cmd, :number
4
+
5
+ @@bookmark_number = 1
6
+
7
+ def self.new_from_json json
8
+ obj = new
9
+ # We are looking at a deep nested hash if we have more than 1 values.
10
+ if json.length == 1
11
+ obj.name = json.keys.first
12
+ obj.children = json.values.flatten.map do |h|
13
+ # Recursive extract again
14
+ new_from_json h
15
+ end
16
+ else
17
+ obj.name = json[:name]
18
+ obj.cmd = json[:cmd]
19
+ end
20
+ obj.number = @@bookmark_number
21
+ @@bookmark_number += 1
22
+ obj
23
+ end
24
+
25
+ def to_a
26
+ [number, name, cmd]
27
+ end
28
+
29
+ def connect
30
+ system(cmd)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+ module ShuttleCli
2
+ class Printer
3
+ def print
4
+ rows = bookmarks.map(&:to_a)
5
+ table = Terminal::Table.new :rows => rows, headings: %w[number name command]
6
+ puts table
7
+ end
8
+
9
+ def bookmarks
10
+ reader.bookmarks
11
+ end
12
+
13
+ def bookmark_by_number number
14
+ bookmark = bookmarks.select {|bm| bm.number == number.to_i }[0]
15
+ raise ArgumentError, "Please provide a valid bookmark number" unless bookmark
16
+ bookmark
17
+ end
18
+
19
+ def connect_to_number number
20
+ bookmark = bookmark_by_number number
21
+ bookmark.connect
22
+ end
23
+
24
+ def reader
25
+ @reader ||= Reader.new
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,38 @@
1
+ module ShuttleCli
2
+ class Reader
3
+ attr_accessor :bookmarks
4
+
5
+ def initialize
6
+ self.bookmarks = load_bookmarks
7
+ self
8
+ end
9
+
10
+ def load_bookmarks
11
+ json = bookmarks_json.with_indifferent_access
12
+ hosts = json[:hosts].flatten
13
+ converted = hosts.map do |h|
14
+ Bookmark.new_from_json h
15
+ end
16
+ # For now flatten all.
17
+ converted.map do |b|
18
+ if b.children
19
+ b.children
20
+ else
21
+ b
22
+ end
23
+ end.flatten
24
+ end
25
+
26
+ def json_location
27
+ open(ENV['HOME']+'/.shuttle.json')
28
+ end
29
+
30
+ def json_file_content
31
+ File.open(json_location, "rb") {|f| f.read }
32
+ end
33
+
34
+ def bookmarks_json
35
+ JSON.parse json_file_content
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module ShuttleCli
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'shuttle_cli/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "shuttle_cli"
8
+ spec.version = ShuttleCli::VERSION
9
+ spec.authors = ["Hendrik Kleinwaechter"]
10
+ spec.email = ["hendrik.kleinwaechter@gmail.com"]
11
+ spec.summary = %q{Command line interface for the Mac Shuttle SSH Client}
12
+ spec.description = %q{For people who work in the Terminal. This provides a command line interface with all your SSH bookmarks.}
13
+ spec.homepage = "http://github.com/hendricius/shuttle-cli"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "terminal-table", "1.4.5"
22
+ spec.add_runtime_dependency "json", "1.8"
23
+ spec.add_runtime_dependency "activesupport", "4.1.7"
24
+ spec.add_runtime_dependency "i18n", "0.6.9"
25
+ spec.add_runtime_dependency "tzinfo", "1.1"
26
+ spec.add_runtime_dependency "minitest", "5.1"
27
+ spec.add_runtime_dependency "thread_safe", "0.3.4"
28
+ spec.add_development_dependency "bundler", '1.7.6'
29
+ spec.add_development_dependency "rake", "10.3.2"
30
+ spec.add_development_dependency "pry", "0.10.1"
31
+
32
+ end
metadata ADDED
@@ -0,0 +1,198 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shuttle_cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Hendrik Kleinwaechter
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: terminal-table
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.4.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.4.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 4.1.7
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 4.1.7
55
+ - !ruby/object:Gem::Dependency
56
+ name: i18n
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.6.9
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.6.9
69
+ - !ruby/object:Gem::Dependency
70
+ name: tzinfo
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: '1.1'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: '1.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: '5.1'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: '5.1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: thread_safe
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.3.4
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.3.4
111
+ - !ruby/object:Gem::Dependency
112
+ name: bundler
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 1.7.6
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 1.7.6
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 10.3.2
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 10.3.2
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 0.10.1
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 0.10.1
153
+ description: For people who work in the Terminal. This provides a command line interface
154
+ with all your SSH bookmarks.
155
+ email:
156
+ - hendrik.kleinwaechter@gmail.com
157
+ executables:
158
+ - shuttle
159
+ extensions: []
160
+ extra_rdoc_files: []
161
+ files:
162
+ - ".gitignore"
163
+ - Gemfile
164
+ - LICENSE.txt
165
+ - README.md
166
+ - Rakefile
167
+ - bin/shuttle
168
+ - lib/shuttle_cli.rb
169
+ - lib/shuttle_cli/bookmark.rb
170
+ - lib/shuttle_cli/printer.rb
171
+ - lib/shuttle_cli/reader.rb
172
+ - lib/shuttle_cli/version.rb
173
+ - shuttle_cli.gemspec
174
+ homepage: http://github.com/hendricius/shuttle-cli
175
+ licenses:
176
+ - MIT
177
+ metadata: {}
178
+ post_install_message:
179
+ rdoc_options: []
180
+ require_paths:
181
+ - lib
182
+ required_ruby_version: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ required_rubygems_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ requirements: []
193
+ rubyforge_project:
194
+ rubygems_version: 2.2.2
195
+ signing_key:
196
+ specification_version: 4
197
+ summary: Command line interface for the Mac Shuttle SSH Client
198
+ test_files: []