heroshell 1.0.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 +7 -0
- data/bin/heroshell +4 -0
- data/lib/heroshell/heroku_command_cache.rb +43 -0
- data/lib/heroshell.rb +51 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0168186a719d837e1cadd02d9e2d3d9591d96517
|
4
|
+
data.tar.gz: 7342cafdf8db897f76814d935246ecc17e1196c8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6f99fe2ff575bd7d0ba8d4b1079db62d0697b4006899f447e5f16e7473083f9b383433d02ae908e1c05d79ab1af73e2fdc5bee00982395ae18c42d127f23336a
|
7
|
+
data.tar.gz: 0294c691178215be8a728110ca4ca0d82cfdfe7f14930da59f51edda4e347ab06e876cd73bd0d69c1e796f3fc55097c588d42c676b51403f8d4182b2e4ffa976
|
data/bin/heroshell
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
class HeroShell::HerokuCommandsCache
|
2
|
+
@@TOPICS_FILE = "#{ENV['HOME']}/.heroku-commands.list"
|
3
|
+
|
4
|
+
def self.sync()
|
5
|
+
def self.read_help_topics()
|
6
|
+
lines = `heroku help`.split("\n").drop(4)
|
7
|
+
lines
|
8
|
+
.select { |l| l[1] != ' ' }
|
9
|
+
.collect { |l| l.strip().split(' ')[0] }
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.read_topic(topic)
|
13
|
+
lines = `heroku help #{topic}`.split("\n")
|
14
|
+
lines
|
15
|
+
.drop_while { |line| !line.start_with? " -a, --app" }
|
16
|
+
.drop_while { |line| !line.start_with? "heroku #{topic} commands" }
|
17
|
+
.drop(1)
|
18
|
+
.select { |l| l[1] != ' ' }
|
19
|
+
.collect { |l| l.strip().split(' ')[0] }
|
20
|
+
end
|
21
|
+
|
22
|
+
File.open(@@TOPICS_FILE, "w+") { |f|
|
23
|
+
f.write(read_help_topics()
|
24
|
+
.flat_map{ |t| read_topic(t) }
|
25
|
+
.join("\n"))
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.get_commands()
|
30
|
+
def self.read_topics_file()
|
31
|
+
IO.read(@@TOPICS_FILE).split("\n")
|
32
|
+
end
|
33
|
+
|
34
|
+
if File.exist? @@TOPICS_FILE
|
35
|
+
read_topics_file()
|
36
|
+
else
|
37
|
+
puts "No commands file found - syncing.."
|
38
|
+
sync()
|
39
|
+
puts "Syncing done."
|
40
|
+
read_topics_file()
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/heroshell.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require "readline"
|
2
|
+
require "rainbow"
|
3
|
+
|
4
|
+
|
5
|
+
class HeroShell
|
6
|
+
def initialize(herokuApp)
|
7
|
+
unless herokuApp
|
8
|
+
puts "switcher <herokuApp>"
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
@app = herokuApp
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def init_completion()
|
16
|
+
autocompleted_commands = HerokuCommandsCache.get_commands()
|
17
|
+
Readline.completion_append_character = " "
|
18
|
+
Readline.completion_proc = proc { |s|
|
19
|
+
autocompleted_commands.grep(/^#{Regexp.escape(s)}/)
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def run()
|
24
|
+
init_completion()
|
25
|
+
while buf = Readline.readline("(#{Rainbow(@app).red})> ", false)
|
26
|
+
buf = buf.strip()
|
27
|
+
if buf.empty?
|
28
|
+
next
|
29
|
+
end
|
30
|
+
if buf.start_with?("switch ")
|
31
|
+
switchTo = buf.split(" ")[1]
|
32
|
+
if switchTo
|
33
|
+
@app = switchTo
|
34
|
+
Readline::HISTORY.push(buf)
|
35
|
+
else
|
36
|
+
$stderr.puts "use: \"switch <herokuApp>\" to switch to other app"
|
37
|
+
end
|
38
|
+
else
|
39
|
+
command = "heroku #{buf} -a #{@app}"
|
40
|
+
res = system(command)
|
41
|
+
if res
|
42
|
+
Readline::HISTORY.push(buf)
|
43
|
+
else
|
44
|
+
$stderr.puts "Command \"#{command}\" returned non-zero status."
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
require "heroshell/heroku_command_cache"
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: heroshell
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jakub Janczak (@kubek2k)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rainbow
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.2.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.2.2
|
27
|
+
description: Heroku command shell
|
28
|
+
email: kubek2k@gmail.com
|
29
|
+
executables:
|
30
|
+
- heroshell
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- bin/heroshell
|
35
|
+
- lib/heroshell.rb
|
36
|
+
- lib/heroshell/heroku_command_cache.rb
|
37
|
+
homepage: http://rubygems.org/gems/heroshell
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 2.4.5.2
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Heroku command shell
|
61
|
+
test_files: []
|