dogids-cli 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +22 -0
- data/LICENSE +8 -0
- data/README.md +31 -0
- data/bin/dogids +11 -0
- data/dogids_cli.gemspec +20 -0
- data/lib/dogids.rb +3 -0
- data/lib/dogids/base.rb +62 -0
- data/lib/dogids/ssh.rb +25 -0
- data/lib/dogids/ssh/development.rb +23 -0
- data/lib/dogids/ssh/production.rb +23 -0
- data/lib/dogids/version.rb +36 -0
- data/resources/temp/.keep +0 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 53570093af825496ddb8bacb9febac6e01407e7a
|
4
|
+
data.tar.gz: 2c76d2ce66616344b3776c8bc6c638cc3671692a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9489955e256da702b9227d6b433831b69a3b6b43cceed3d7c300a31ff7535eb288cc2a2e0e47b0544a01a60e1022550648853bb5f50384836a8683e7d15fa239
|
7
|
+
data.tar.gz: fb4857a22eeec92c058da5d376f1c7c92b05b1588bbb89550299c18f29b5b841688b02fafff6b4af1daf2d50fbb3f044848f77a942949efff83c26b43168bb56
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
codelation-cli (0.0.2)
|
5
|
+
open_uri_redirections (~> 0.2)
|
6
|
+
progressbar (~> 0.21)
|
7
|
+
rubyzip (~> 1.1)
|
8
|
+
thor (~> 0.19)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
open_uri_redirections (0.2.1)
|
14
|
+
progressbar (0.21.0)
|
15
|
+
rubyzip (1.1.7)
|
16
|
+
thor (0.19.1)
|
17
|
+
|
18
|
+
PLATFORMS
|
19
|
+
ruby
|
20
|
+
|
21
|
+
DEPENDENCIES
|
22
|
+
codelation-cli!
|
data/LICENSE
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
Name: dogids-cli
|
2
|
+
Copyright (c) 2015 Brian Pattison
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7
|
+
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# DogIDs CLI
|
2
|
+
|
3
|
+
Command line tool for DogIDs tasks.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
$ gem install dogids-cli
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```
|
16
|
+
$ dogids help
|
17
|
+
|
18
|
+
Commands:
|
19
|
+
dogids help [COMMAND] # Describe available commands or one specific command
|
20
|
+
dogids ssh # List available SSH commands
|
21
|
+
dogids update # Update dogids-cli to latest version
|
22
|
+
dogids version # Show version information
|
23
|
+
```
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/dogids-cli/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/bin/dogids
ADDED
data/dogids_cli.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "dogids/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "dogids-cli"
|
8
|
+
spec.version = Dogids::VERSION
|
9
|
+
spec.authors = ["Brian Pattison"]
|
10
|
+
spec.email = ["brian@brianpattison.com"]
|
11
|
+
spec.summary = "Command line tool for dogIDs tasks"
|
12
|
+
spec.homepage = "https://github.com/dogIDs/dogids-cli"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency "thor", "~> 0.19"
|
20
|
+
end
|
data/lib/dogids.rb
ADDED
data/lib/dogids/base.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require "json"
|
2
|
+
require "net/http"
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
module Dogids
|
6
|
+
class Cli < Thor
|
7
|
+
include Thor::Actions
|
8
|
+
# Add the ablitity to print help for commands like:
|
9
|
+
# `dogids help development:install`
|
10
|
+
# This would print help for the method:
|
11
|
+
# `development_install`
|
12
|
+
# @param method [String]
|
13
|
+
def help(method = nil)
|
14
|
+
if method.to_s.split(":").length >= 2
|
15
|
+
method = method.to_s.gsub(":", "_")
|
16
|
+
elsif method.to_s == "run"
|
17
|
+
method = "walk"
|
18
|
+
end
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
# Add the ablitity to run commands like:
|
23
|
+
# `dogids development:install`
|
24
|
+
# This would run the defined method:
|
25
|
+
# `development_install`
|
26
|
+
def method_missing(method, *args, &block)
|
27
|
+
if method.to_s.split(":").length >= 2
|
28
|
+
self.send(method.to_s.gsub(":", "_"), *args)
|
29
|
+
elsif method.to_s == "run"
|
30
|
+
self.walk(*args)
|
31
|
+
else
|
32
|
+
super
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# This is the directory where your templates should be placed.
|
37
|
+
def self.source_root
|
38
|
+
File.expand_path("../../../resources", __FILE__)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
# Print a heading to the terminal for commands that are going to be run.
|
44
|
+
# @param heading [String]
|
45
|
+
def print_heading(heading)
|
46
|
+
puts "-----> #{heading}"
|
47
|
+
end
|
48
|
+
|
49
|
+
# Print a message to the terminal about a command that's going to run.
|
50
|
+
# @param command [String]
|
51
|
+
def print_command(command)
|
52
|
+
puts " #{command}"
|
53
|
+
end
|
54
|
+
|
55
|
+
# Run a command with Bash after first printing the command to the terminal.
|
56
|
+
# @param command [String]
|
57
|
+
def run_command(command)
|
58
|
+
print_command(command)
|
59
|
+
`#{command}`
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/dogids/ssh.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "thor"
|
2
|
+
require_relative "ssh/development"
|
3
|
+
require_relative "ssh/production"
|
4
|
+
|
5
|
+
module Dogids
|
6
|
+
class Cli < Thor
|
7
|
+
desc "ssh", "List available SSH commands"
|
8
|
+
def ssh(vm_name = nil)
|
9
|
+
if vm_name
|
10
|
+
ssh_development(vm_name)
|
11
|
+
else
|
12
|
+
puts "Development SSH Commands:"
|
13
|
+
puts " dogids ssh db # SSH into local MySQL/Redis VM"
|
14
|
+
puts " dogids ssh web # SSH into local Apache/PHP VM"
|
15
|
+
puts " dogids ssh worker # SSH into local Ruby/Sidekiq VM"
|
16
|
+
puts " "
|
17
|
+
puts "Production SSH Commands:"
|
18
|
+
puts " dogids ssh:production db # SSH into production MySQL/Redis VM"
|
19
|
+
puts " dogids ssh:production web # SSH into production Apache/PHP VM"
|
20
|
+
puts " dogids ssh:production worker # SSH into production Ruby/Sidekiq VM"
|
21
|
+
puts " "
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module Dogids
|
4
|
+
class Cli < Thor
|
5
|
+
no_commands do
|
6
|
+
def ssh_development(vm_name = nil)
|
7
|
+
case vm_name
|
8
|
+
when "db"
|
9
|
+
puts "Running: ssh -R 52698:localhost:52698 dogids@55.55.55.10"
|
10
|
+
exec("ssh -R 52698:localhost:52698 dogids@55.55.55.10")
|
11
|
+
when "web"
|
12
|
+
puts "Running: ssh -R 52698:localhost:52698 dogids@55.55.55.20"
|
13
|
+
exec("ssh -R 52698:localhost:52698 dogids@55.55.55.20")
|
14
|
+
when "worker"
|
15
|
+
puts "Running: ssh -R 52698:localhost:52698 dogids@55.55.55.30"
|
16
|
+
exec("ssh -R 52698:localhost:52698 dogids@55.55.55.30")
|
17
|
+
else
|
18
|
+
ssh
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module Dogids
|
4
|
+
class Cli < Thor
|
5
|
+
no_commands do
|
6
|
+
def ssh_production(vm_name = nil)
|
7
|
+
case vm_name
|
8
|
+
when "db"
|
9
|
+
puts "Running: `ssh -R 52698:localhost:52698 dogids@db1.dogids.codelation.net`"
|
10
|
+
exec("ssh -R 52698:localhost:52698 dogids@db1.dogids.codelation.net")
|
11
|
+
when "web"
|
12
|
+
puts "Running: `ssh -R 52698:localhost:52698 dogids@web1.dogids.codelation.net`"
|
13
|
+
exec("ssh -R 52698:localhost:52698 dogids@web1.dogids.codelation.net")
|
14
|
+
when "worker"
|
15
|
+
puts "Running: `ssh -R 52698:localhost:52698 dogids@worker1.dogids.codelation.net`"
|
16
|
+
exec("ssh -R 52698:localhost:52698 dogids@worker1.dogids.codelation.net")
|
17
|
+
else
|
18
|
+
ssh
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "json"
|
2
|
+
require "open-uri"
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
module Dogids
|
6
|
+
VERSION = "0.0.1"
|
7
|
+
|
8
|
+
class Cli < Thor
|
9
|
+
desc "update", "Update dogids-cli to latest version"
|
10
|
+
def update
|
11
|
+
command = "gem install dogids-cli"
|
12
|
+
puts "Running #{command}..."
|
13
|
+
exec(command)
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "version", "Show version information"
|
17
|
+
def version
|
18
|
+
gem_version = "v#{Dogids::VERSION}"
|
19
|
+
|
20
|
+
# Grab the latest version of the RubyGem
|
21
|
+
rubygems_json = open("https://rubygems.org/api/v1/gems/dogids-cli.json").read
|
22
|
+
rubygems_version = "v#{JSON.parse(rubygems_json)['version'].strip}"
|
23
|
+
|
24
|
+
upgrade_message = ""
|
25
|
+
if gem_version != rubygems_version
|
26
|
+
upgrade_message = " Run `dogids update` to install"
|
27
|
+
end
|
28
|
+
|
29
|
+
puts
|
30
|
+
puts "Dogids CLI"
|
31
|
+
puts " Installed: #{gem_version}"
|
32
|
+
puts " Latest: #{rubygems_version}#{upgrade_message}"
|
33
|
+
puts
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dogids-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Pattison
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.19'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.19'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- brian@brianpattison.com
|
30
|
+
executables:
|
31
|
+
- dogids
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".gitignore"
|
36
|
+
- Gemfile
|
37
|
+
- Gemfile.lock
|
38
|
+
- LICENSE
|
39
|
+
- README.md
|
40
|
+
- bin/dogids
|
41
|
+
- dogids_cli.gemspec
|
42
|
+
- lib/dogids.rb
|
43
|
+
- lib/dogids/base.rb
|
44
|
+
- lib/dogids/ssh.rb
|
45
|
+
- lib/dogids/ssh/development.rb
|
46
|
+
- lib/dogids/ssh/production.rb
|
47
|
+
- lib/dogids/version.rb
|
48
|
+
- resources/temp/.keep
|
49
|
+
homepage: https://github.com/dogIDs/dogids-cli
|
50
|
+
licenses:
|
51
|
+
- MIT
|
52
|
+
metadata: {}
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
requirements: []
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 2.4.5
|
70
|
+
signing_key:
|
71
|
+
specification_version: 4
|
72
|
+
summary: Command line tool for dogIDs tasks
|
73
|
+
test_files: []
|
74
|
+
has_rdoc:
|