morpheus-cli 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/morpheus/cli/key_pairs.rb +13 -8
- data/lib/morpheus/cli/option_types.rb +6 -3
- data/lib/morpheus/cli/shell.rb +19 -2
- data/lib/morpheus/cli/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: 7f4478e92b5478811a8d5520c5295009bc6a9547
|
4
|
+
data.tar.gz: 7bacea0771637cf3e033e5c962bbe2f1e0bd67f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3039dd65f5c4a4e56c9efcb89db550183e8c2e0ed36ccafcd97a2ab2efb7763ca8d1f4ee7a32d01e1f6ee20e5f9c44681d96f11bcc658d8fe21a33bc19513a9e
|
7
|
+
data.tar.gz: d876f23eafb32db8354b7805dde7814b477c37b966adeb4e50a1e02834fa14684073e5e46706bb3f8c716a94a6f05cf6a04bf5f91e600ea4e4d88187e2945e95
|
@@ -148,17 +148,18 @@ class Morpheus::Cli::KeyPairs
|
|
148
148
|
# exit 1
|
149
149
|
# end
|
150
150
|
account_name = nil
|
151
|
+
keypair_name = args[0]
|
151
152
|
options = {}
|
152
153
|
optparse = OptionParser.new do|opts|
|
153
|
-
opts.banner = "Usage: morpheus key-pairs add [options]"
|
154
|
+
opts.banner = "Usage: morpheus key-pairs add [name] [options]"
|
154
155
|
|
155
156
|
opts.on( '-a', '--account ACCOUNT', "Account Name" ) do |val|
|
156
157
|
account_name = val
|
157
158
|
end
|
158
159
|
|
159
160
|
opts.on( '', '--public-key-file FILENAME', "Public Key File" ) do |filename|
|
160
|
-
if File.exists?(filename)
|
161
|
-
options['publicKey'] = File.read(filename)
|
161
|
+
if File.exists?(File.expand_path(filename))
|
162
|
+
options['publicKey'] = File.read(File.expand_path(filename))
|
162
163
|
options[:options] ||= {}
|
163
164
|
options[:options]['publicKey'] = options['publicKey']
|
164
165
|
else
|
@@ -174,8 +175,8 @@ class Morpheus::Cli::KeyPairs
|
|
174
175
|
end
|
175
176
|
|
176
177
|
opts.on( '', '--private-key-file FILENAME', "Private Key File" ) do |filename|
|
177
|
-
if File.exists?(filename)
|
178
|
-
options['privateKey'] = File.read(filename)
|
178
|
+
if File.exists?(File.expand_path(filename))
|
179
|
+
options['privateKey'] = File.read(File.expand_path(filename))
|
179
180
|
options[:options] ||= {}
|
180
181
|
options[:options]['privateKey'] = options['privateKey']
|
181
182
|
else
|
@@ -192,6 +193,10 @@ class Morpheus::Cli::KeyPairs
|
|
192
193
|
|
193
194
|
Morpheus::Cli::CliCommand.genericOptions(opts,options)
|
194
195
|
end
|
196
|
+
if args.count < 1
|
197
|
+
puts "\n#{optparse}\n\n"
|
198
|
+
exit 1
|
199
|
+
end
|
195
200
|
optparse.parse(args)
|
196
201
|
|
197
202
|
connect(options)
|
@@ -215,12 +220,13 @@ class Morpheus::Cli::KeyPairs
|
|
215
220
|
print_red_alert "privateKey is required"
|
216
221
|
exit 1
|
217
222
|
end
|
223
|
+
params['name'] = args[0]
|
218
224
|
|
219
|
-
key_pair_payload = params.select {|k,v| ['name',
|
225
|
+
key_pair_payload = params.select {|k,v| ['name','publicKey', 'privateKey'].include?(k) }
|
220
226
|
|
221
227
|
request_payload = {keyPair: key_pair_payload}
|
222
228
|
response = @key_pairs_interface.create(account_id, request_payload)
|
223
|
-
print "\n", cyan, "
|
229
|
+
print "\n", cyan, "Keypair #{key_pair_payload['name']} added", reset, "\n\n"
|
224
230
|
rescue RestClient::Exception => e
|
225
231
|
::Morpheus::Cli::ErrorHandler.new.print_rest_exception(e)
|
226
232
|
exit 1
|
@@ -378,7 +384,6 @@ private
|
|
378
384
|
|
379
385
|
def add_key_pair_option_types
|
380
386
|
[
|
381
|
-
{'fieldName' => 'name', 'fieldLabel' => 'Name', 'type' => 'text', 'required' => true, 'displayOrder' => 1},
|
382
387
|
{'fieldName' => 'publicKey', 'fieldLabel' => 'Public Key', 'type' => 'text', 'required' => true, 'displayOrder' => 2},
|
383
388
|
{'fieldName' => 'privateKey', 'fieldLabel' => 'Private Key', 'type' => 'text', 'required' => true, 'displayOrder' => 3},
|
384
389
|
]
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'term/ansicolor'
|
2
|
-
|
2
|
+
require 'readline'
|
3
3
|
module Morpheus
|
4
4
|
module Cli
|
5
5
|
module OptionTypes
|
@@ -138,8 +138,11 @@ module Morpheus
|
|
138
138
|
value = source_option['value']
|
139
139
|
end
|
140
140
|
while !value_found do
|
141
|
-
|
142
|
-
|
141
|
+
Readline.completion_append_character = ""
|
142
|
+
Readline.basic_word_break_characters = ''
|
143
|
+
Readline.completion_proc = proc {|s| source_options.collect{|opt| opt['name']}.grep(/^#{Regexp.escape(s)}/)}
|
144
|
+
input = Readline.readline("#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? ('(' + option_type['fieldAddOn'] + ') ') : '' }#{!option_type['required'] ? ' (optional)' : ''} ['?' for options]: ", false).to_s
|
145
|
+
input = input.chomp.strip
|
143
146
|
if option_type['optionSource']
|
144
147
|
source_option = source_options.find{|b| b['name'] == input || (!b['value'].nil? && b['value'].to_s == input) || (b['value'].nil? && input.empty?)}
|
145
148
|
if source_option
|
data/lib/morpheus/cli/shell.rb
CHANGED
@@ -6,6 +6,7 @@ require 'optparse'
|
|
6
6
|
require 'table_print'
|
7
7
|
require 'morpheus/cli/cli_command'
|
8
8
|
require "shellwords"
|
9
|
+
require 'readline'
|
9
10
|
|
10
11
|
|
11
12
|
class Morpheus::Cli::Shell
|
@@ -13,6 +14,17 @@ class Morpheus::Cli::Shell
|
|
13
14
|
include Term::ANSIColor
|
14
15
|
def initialize()
|
15
16
|
@appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance
|
17
|
+
@auto_complete = proc do |s|
|
18
|
+
command_list = Morpheus::Cli::CliRegistry.all.keys
|
19
|
+
result = command_list.grep(/^#{Regexp.escape(s)}/)
|
20
|
+
if result.nil? || result.empty?
|
21
|
+
Readline::FILENAME_COMPLETION_PROC.call(s)
|
22
|
+
else
|
23
|
+
result
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
16
28
|
end
|
17
29
|
|
18
30
|
def handle(args)
|
@@ -41,8 +53,12 @@ class Morpheus::Cli::Shell
|
|
41
53
|
remote_handler = Morpheus::Cli::Remote.new()
|
42
54
|
exit = false
|
43
55
|
while !exit do
|
44
|
-
|
45
|
-
|
56
|
+
Readline.completion_append_character = " "
|
57
|
+
Readline.completion_proc = @auto_complete
|
58
|
+
Readline.basic_word_break_characters = "\t\n\"\‘`@$><=;|&{( "
|
59
|
+
input = Readline.readline("#{cyan}morpheus> #{reset}", true).to_s
|
60
|
+
# print cyan,"morpheus > ",reset
|
61
|
+
# input = $stdin.gets.chomp!
|
46
62
|
if !input.empty?
|
47
63
|
|
48
64
|
if input == 'exit'
|
@@ -85,6 +101,7 @@ class Morpheus::Cli::Shell
|
|
85
101
|
puts "Argument Syntax Error..."
|
86
102
|
rescue SystemExit, Interrupt
|
87
103
|
# nothing to do
|
104
|
+
puts "Interrupted..."
|
88
105
|
rescue => e
|
89
106
|
print red, "\n", e.message, "\n", reset
|
90
107
|
print e.backtrace.join("\n"), "\n"
|
data/lib/morpheus/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: morpheus-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Estes
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-09-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|