blockspring-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.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +49 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/bin/blockspring +14 -0
- data/blockspring-cli.gemspec +26 -0
- data/lib/blockspring/cli/auth.rb +135 -0
- data/lib/blockspring/cli/command/auth.rb +22 -0
- data/lib/blockspring/cli/command/base.rb +35 -0
- data/lib/blockspring/cli/command/block.rb +125 -0
- data/lib/blockspring/cli/command/help.rb +9 -0
- data/lib/blockspring/cli/command/run.rb +15 -0
- data/lib/blockspring/cli/command/version.rb +7 -0
- data/lib/blockspring/cli/command.rb +39 -0
- data/lib/blockspring/cli/version.rb +5 -0
- data/lib/blockspring/cli.rb +41 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4060661d1bbb9771a428022b003a7fd004b5a514
|
4
|
+
data.tar.gz: 8ce83e546e1756c4f64647a30645d50ec6e272dc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a20065e1cb01b39504754e3d43f7159ce5e6390916da649a66c10bbf02f83a14f03fc4278772c6db0e9181d550f66b9f50a1b0c11efd66fceae686d681008817
|
7
|
+
data.tar.gz: c9b281cc0fa15dde977720e7ef3b13282985f3a5da2b711ef69e6645732d2d9266de9cacf29da77df2c3bb016b49cacdc00798743d2c3827f0d2b91ce48687c3
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
Copyright (c) Grafly, Inc. (Blockspring)
|
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.
|
23
|
+
|
24
|
+
|
25
|
+
Third-Party Licenses
|
26
|
+
|
27
|
+
|
28
|
+
The MIT License (MIT)
|
29
|
+
|
30
|
+
Copyright © Heroku 2008 - 2012
|
31
|
+
|
32
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
33
|
+
a copy of this software and associated documentation files (the
|
34
|
+
"Software"), to deal in the Software without restriction, including
|
35
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
36
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
37
|
+
permit persons to whom the Software is furnished to do so, subject to
|
38
|
+
the following conditions:
|
39
|
+
|
40
|
+
The above copyright notice and this permission notice shall be
|
41
|
+
included in all copies or substantial portions of the Software.
|
42
|
+
|
43
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
44
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
45
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
46
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
47
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
48
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
49
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Blockspring::Cli
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'blockspring-cli'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install blockspring-cli
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/blockspring-cli/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/blockspring
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
# resolve bin path, ignoring symlinks
|
5
|
+
require "pathname"
|
6
|
+
bin_file = Pathname.new(__FILE__).realpath
|
7
|
+
|
8
|
+
# add self to libpath
|
9
|
+
$:.unshift File.expand_path("../../lib", bin_file)
|
10
|
+
|
11
|
+
# start up the CLI
|
12
|
+
require "blockspring/cli"
|
13
|
+
Blockspring::CLI.user_agent = "blockspring-cli-gem/#{Blockspring::CLI::VERSION} (#{RUBY_PLATFORM}) ruby/#{RUBY_VERSION}"
|
14
|
+
Blockspring::CLI.start(*ARGV)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'blockspring/cli/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "blockspring-cli"
|
8
|
+
spec.version = Blockspring::CLI::VERSION
|
9
|
+
spec.authors = ["Blockspring"]
|
10
|
+
spec.email = ["founders@blockspring.com"]
|
11
|
+
spec.summary = "This is the command line helper for blockspring"
|
12
|
+
spec.description = "This is the command line helper for blockspring"
|
13
|
+
spec.homepage = "http://www.blockspring.com"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = "blockspring"
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency "netrc", "~> 0.8.0"
|
25
|
+
spec.add_dependency "rest-client", "= 1.7.2"
|
26
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
require 'netrc'
|
2
|
+
require 'rest_client'
|
3
|
+
|
4
|
+
class Blockspring::CLI::Auth
|
5
|
+
class << self
|
6
|
+
def host
|
7
|
+
ENV['BLOCKSPRING_API_HOST'] || 'localhost:3000'
|
8
|
+
end
|
9
|
+
|
10
|
+
# TODO: change to https
|
11
|
+
def base_url
|
12
|
+
protocol = ENV['BLOCKSPRING_API_PROTOCOL'] || 'http'
|
13
|
+
"#{protocol}://#{host}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def with_tty(&block)
|
17
|
+
return unless $stdin.isatty
|
18
|
+
begin
|
19
|
+
yield
|
20
|
+
rescue
|
21
|
+
# fails on windows
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def echo_off
|
26
|
+
with_tty do
|
27
|
+
system "stty -echo"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def echo_on
|
32
|
+
with_tty do
|
33
|
+
system "stty echo"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def ask
|
38
|
+
$stdin.gets.to_s.strip
|
39
|
+
end
|
40
|
+
|
41
|
+
def ask_for_password
|
42
|
+
begin
|
43
|
+
echo_off
|
44
|
+
password = ask
|
45
|
+
puts
|
46
|
+
ensure
|
47
|
+
echo_on
|
48
|
+
end
|
49
|
+
return password
|
50
|
+
end
|
51
|
+
|
52
|
+
def ask_for_credentials
|
53
|
+
puts "Enter your Blockspring credentials."
|
54
|
+
|
55
|
+
print "Username or email: "
|
56
|
+
login = ask
|
57
|
+
|
58
|
+
print "Password (typing will be hidden): "
|
59
|
+
password = ask_for_password
|
60
|
+
|
61
|
+
[login, api_key(login, password)]
|
62
|
+
end
|
63
|
+
|
64
|
+
def api_key(login, password)
|
65
|
+
response = RestClient.post "#{base_url}/cli/login", { login: login, password: password }, user_agent: Blockspring::CLI.user_agent
|
66
|
+
if response.code == 200
|
67
|
+
response.to_str
|
68
|
+
else
|
69
|
+
raise 'login failed'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def reauthorize
|
74
|
+
@credentials = ask_for_and_save_credentials
|
75
|
+
end
|
76
|
+
|
77
|
+
def delete_credentials
|
78
|
+
if netrc
|
79
|
+
netrc.delete(host)
|
80
|
+
netrc.save
|
81
|
+
end
|
82
|
+
@credentials = nil
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_credentials
|
86
|
+
@credentials ||= (read_credentials || ask_for_and_save_credentials)
|
87
|
+
end
|
88
|
+
|
89
|
+
def ask_for_and_save_credentials
|
90
|
+
@credentials = ask_for_credentials
|
91
|
+
write_credentials
|
92
|
+
@credentials
|
93
|
+
end
|
94
|
+
|
95
|
+
def write_credentials
|
96
|
+
FileUtils.mkdir_p(File.dirname(netrc_path))
|
97
|
+
FileUtils.touch(netrc_path)
|
98
|
+
netrc[host] = @credentials
|
99
|
+
netrc.save
|
100
|
+
end
|
101
|
+
|
102
|
+
def netrc_path
|
103
|
+
default = Netrc.default_path
|
104
|
+
encrypted = default + ".gpg"
|
105
|
+
if File.exists?(encrypted)
|
106
|
+
encrypted
|
107
|
+
else
|
108
|
+
default
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def netrc # :nodoc:
|
113
|
+
@netrc ||= begin
|
114
|
+
File.exists?(netrc_path) && Netrc.read(netrc_path)
|
115
|
+
rescue => error
|
116
|
+
if error.message =~ /^Permission bits for/
|
117
|
+
perm = File.stat(netrc_path).mode & 0777
|
118
|
+
abort("Permissions #{perm} for '#{netrc_path}' are too open. You should run `chmod 0600 #{netrc_path}` so that your credentials are NOT accessible by others.")
|
119
|
+
else
|
120
|
+
raise error
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def read_credentials
|
126
|
+
if ENV['BLOCKSPRING_API_KEY']
|
127
|
+
['', ENV['BLOCKSPRING_API_KEY']]
|
128
|
+
else
|
129
|
+
if netrc
|
130
|
+
netrc[host]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "blockspring/cli/command/base"
|
2
|
+
|
3
|
+
class Blockspring::CLI::Command::Auth < Blockspring::CLI::Command::Base
|
4
|
+
def index
|
5
|
+
user, _key = Blockspring::CLI::Auth.get_credentials
|
6
|
+
if user
|
7
|
+
puts "You are logged in as #{user}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def login
|
12
|
+
Blockspring::CLI::Auth.reauthorize
|
13
|
+
end
|
14
|
+
|
15
|
+
def logout
|
16
|
+
Blockspring::CLI::Auth.delete_credentials
|
17
|
+
puts "You have been logged out"
|
18
|
+
end
|
19
|
+
|
20
|
+
alias_command 'login', 'auth:login'
|
21
|
+
alias_command 'logout', 'auth:logout'
|
22
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Blockspring::CLI::Command::Base
|
2
|
+
attr_reader :args
|
3
|
+
attr_reader :options
|
4
|
+
|
5
|
+
def self.namespace
|
6
|
+
self.to_s.split("::").last.downcase
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(args=[], options={})
|
10
|
+
@args = args
|
11
|
+
@options = options
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
def self.method_added(method)
|
17
|
+
return if self == Blockspring::CLI::Command::Base
|
18
|
+
return if private_method_defined?(method)
|
19
|
+
return if protected_method_defined?(method)
|
20
|
+
|
21
|
+
resolved_method = (method.to_s == "index") ? nil : method.to_s
|
22
|
+
command = [ self.namespace, resolved_method ].compact.join(":")
|
23
|
+
|
24
|
+
Blockspring::CLI::Command.register_command(
|
25
|
+
:klass => self,
|
26
|
+
:method => method,
|
27
|
+
:command => command
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.alias_command(new, old)
|
32
|
+
raise "no such command: #{old}" unless Blockspring::CLI::Command.commands[old]
|
33
|
+
Blockspring::CLI::Command.command_aliases[new] = old
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require "blockspring/cli/command/base"
|
2
|
+
|
3
|
+
class Blockspring::CLI::Command::Block < Blockspring::CLI::Command::Base
|
4
|
+
def get
|
5
|
+
block_parts = @args[0].split("/")
|
6
|
+
block = get_block(block_parts[block_parts.length - 1])
|
7
|
+
|
8
|
+
dir_name = create_block_directory(block)
|
9
|
+
|
10
|
+
if dir_name
|
11
|
+
save_block_files(block, dir_name)
|
12
|
+
puts "Done."
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
def pull
|
18
|
+
# load config file
|
19
|
+
config_text = File.read('blockspring.json')
|
20
|
+
config_json = JSON.parse(config_text)
|
21
|
+
# TODO: ensure valid config
|
22
|
+
puts "Pulling #{config_json['user']}/#{config_json['id']}"
|
23
|
+
block = get_block(config_json['id'])
|
24
|
+
save_block_files(block, '.')
|
25
|
+
puts "Done."
|
26
|
+
end
|
27
|
+
|
28
|
+
def push
|
29
|
+
_user, key = Blockspring::CLI::Auth.get_credentials
|
30
|
+
config_text = File.read('blockspring.json')
|
31
|
+
config_json = JSON.parse(config_text)
|
32
|
+
# TODO: check for language
|
33
|
+
# language could eventually be js:0.10.x or py:3 or ruby:MRI-2.0
|
34
|
+
script_file = "block.#{config_json['language'].split(':')[0]}"
|
35
|
+
script = File.read(script_file)
|
36
|
+
|
37
|
+
payload = {
|
38
|
+
code: script,
|
39
|
+
config: config_json
|
40
|
+
}
|
41
|
+
|
42
|
+
if config_json['id']
|
43
|
+
uri = "#{Blockspring::CLI::Auth.base_url}/cli/blocks/#{config_json['id']}"
|
44
|
+
else
|
45
|
+
uri = "#{Blockspring::CLI::Auth.base_url}/cli/blocks"
|
46
|
+
end
|
47
|
+
response = RestClient.post uri, payload.to_json, :content_type => :json, :accept => :json, params: { api_key: key }, user_agent: Blockspring::CLI.user_agent
|
48
|
+
json_response = JSON.parse(response.to_str)
|
49
|
+
save_block_files(json_response, '.')
|
50
|
+
end
|
51
|
+
|
52
|
+
def new
|
53
|
+
user, key = Blockspring::CLI::Auth.get_credentials
|
54
|
+
language = @args[0]
|
55
|
+
name = @args[1]
|
56
|
+
|
57
|
+
block = {}
|
58
|
+
|
59
|
+
block['code'] = ""
|
60
|
+
|
61
|
+
block['config'] = {
|
62
|
+
"user" => user,
|
63
|
+
"title" => name,
|
64
|
+
"description" => '',
|
65
|
+
"parameters" => {},
|
66
|
+
"is_public" => false,
|
67
|
+
"language" => language
|
68
|
+
}
|
69
|
+
|
70
|
+
dir_name = create_block_directory(block)
|
71
|
+
if dir_name
|
72
|
+
save_block_files(block, dir_name)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
alias_command "get", "block:get"
|
77
|
+
alias_command "pull", "block:pull"
|
78
|
+
alias_command "push", "block:push"
|
79
|
+
alias_command "new", "block:new"
|
80
|
+
|
81
|
+
protected
|
82
|
+
|
83
|
+
# TODO: move this to another file like 'api'
|
84
|
+
def get_block(block_id)
|
85
|
+
_user, key = Blockspring::CLI::Auth.get_credentials
|
86
|
+
response = RestClient.get "#{Blockspring::CLI::Auth.base_url}/cli/blocks/#{block_id}", params: { api_key: key }, user_agent: Blockspring::CLI.user_agent
|
87
|
+
JSON.parse(response.to_str)
|
88
|
+
end
|
89
|
+
|
90
|
+
def create_block_directory(block)
|
91
|
+
|
92
|
+
dir_name = get_block_directory(block)
|
93
|
+
|
94
|
+
if File.exist?(dir_name) || File.symlink?(dir_name)
|
95
|
+
puts 'Block directory already exists.'
|
96
|
+
return false
|
97
|
+
end
|
98
|
+
|
99
|
+
# create block directory
|
100
|
+
puts "Creating directory #{dir_name}"
|
101
|
+
Dir.mkdir(dir_name)
|
102
|
+
dir_name
|
103
|
+
end
|
104
|
+
|
105
|
+
def get_block_directory(block)
|
106
|
+
slug = block['config']['title'].downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
|
107
|
+
if block['config']['id']
|
108
|
+
"#{slug[0,12]}-#{block['id'][0,8]}"
|
109
|
+
else
|
110
|
+
"#{slug[0,20]}"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def save_block_files(block, dir_name)
|
115
|
+
# create script file
|
116
|
+
script_file = File.join(dir_name, "block.#{block['config']['language'].split(':')[0]}")
|
117
|
+
puts "Syncing script file #{script_file}"
|
118
|
+
File.open(script_file, 'w') { |file| file.write(block['code']) }
|
119
|
+
|
120
|
+
# create config file
|
121
|
+
config_file = File.join(dir_name, "blockspring.json")
|
122
|
+
puts "Syncing config file #{config_file}"
|
123
|
+
File.open(config_file, 'w') { |file| file.write(JSON.pretty_generate(block['config']) + "\n") }
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "blockspring/cli/command/base"
|
2
|
+
|
3
|
+
class Blockspring::CLI::Command::Run < Blockspring::CLI::Command::Base
|
4
|
+
def index
|
5
|
+
if ENV['BLOCKSPRING_API_KEY'].to_s.strip.empty?
|
6
|
+
_, key = Blockspring::CLI::Auth.get_credentials
|
7
|
+
if key
|
8
|
+
ENV['BLOCKSPRING_API_KEY'] = key
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# now run
|
13
|
+
system(*@args)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Blockspring
|
2
|
+
module CLI
|
3
|
+
module Command
|
4
|
+
|
5
|
+
def self.commands
|
6
|
+
@@commands ||= {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.command_aliases
|
10
|
+
@@command_aliases ||= {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.load
|
14
|
+
Dir[File.join(File.dirname(__FILE__), "command", "*.rb")].each do |file|
|
15
|
+
require file
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.register_command(command)
|
20
|
+
commands[command[:command]] = command
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.run(cmd, arguments=[])
|
24
|
+
command = parse(cmd)
|
25
|
+
if command
|
26
|
+
command_instance = command[:klass].new(arguments.dup)
|
27
|
+
command_instance.send(command[:method])
|
28
|
+
else
|
29
|
+
puts "#{cmd} is not a command."
|
30
|
+
puts "See `blockspring help` for a list of commands."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.parse(cmd)
|
35
|
+
commands[cmd] || commands[command_aliases[cmd]]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "blockspring/cli/version"
|
2
|
+
require "blockspring/cli/auth"
|
3
|
+
require "blockspring/cli/command"
|
4
|
+
|
5
|
+
module Blockspring
|
6
|
+
module CLI
|
7
|
+
USER_AGENT = "blockspring-cli-gem/#{Blockspring::CLI::VERSION} (#{RUBY_PLATFORM}) ruby/#{RUBY_VERSION}"
|
8
|
+
|
9
|
+
def self.user_agent
|
10
|
+
@@user_agent ||= USER_AGENT
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.user_agent=(agent)
|
14
|
+
@@user_agent = agent
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.start(*args)
|
18
|
+
begin
|
19
|
+
if $stdin.isatty
|
20
|
+
$stdin.sync = true
|
21
|
+
end
|
22
|
+
if $stdout.isatty
|
23
|
+
$stdout.sync = true
|
24
|
+
end
|
25
|
+
command = args.shift.strip rescue "help"
|
26
|
+
Blockspring::CLI::Command.load
|
27
|
+
Blockspring::CLI::Command.run(command, args)
|
28
|
+
rescue Interrupt => e
|
29
|
+
`stty icanon echo`
|
30
|
+
if ENV["BLOCKSPRING_DEBUG"]
|
31
|
+
puts e.inspect
|
32
|
+
else
|
33
|
+
error("Command cancelled.")
|
34
|
+
end
|
35
|
+
rescue => error
|
36
|
+
puts error.inspect
|
37
|
+
exit(1)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: blockspring-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Blockspring
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: netrc
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.8.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.8.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rest-client
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.7.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.7.2
|
69
|
+
description: This is the command line helper for blockspring
|
70
|
+
email:
|
71
|
+
- founders@blockspring.com
|
72
|
+
executables:
|
73
|
+
- blockspring
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/blockspring
|
83
|
+
- blockspring-cli.gemspec
|
84
|
+
- lib/blockspring/cli.rb
|
85
|
+
- lib/blockspring/cli/auth.rb
|
86
|
+
- lib/blockspring/cli/command.rb
|
87
|
+
- lib/blockspring/cli/command/auth.rb
|
88
|
+
- lib/blockspring/cli/command/base.rb
|
89
|
+
- lib/blockspring/cli/command/block.rb
|
90
|
+
- lib/blockspring/cli/command/help.rb
|
91
|
+
- lib/blockspring/cli/command/run.rb
|
92
|
+
- lib/blockspring/cli/command/version.rb
|
93
|
+
- lib/blockspring/cli/version.rb
|
94
|
+
homepage: http://www.blockspring.com
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.2.2
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: This is the command line helper for blockspring
|
118
|
+
test_files: []
|