rhcp_shell 0.2.11 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/base_shell.rb +1 -0
- data/lib/display_types/hash.rb +10 -0
- data/lib/local_commands/help.rb +6 -1
- data/lib/rhcp_shell_backend.rb +5 -1
- data/lib/version.rb +1 -1
- metadata +13 -13
- data/bin/rhcp_shell.log +0 -11
data/lib/base_shell.rb
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
def format_hash_output(command, response)
|
2
|
+
output = []
|
3
|
+
|
4
|
+
max_key_length = response.data.keys().sort { |a,b| a.length <=> b.length }.first.length
|
5
|
+
|
6
|
+
response.data.each do |k,v|
|
7
|
+
output << sprintf(" %-#{max_key_length + 5}s\t%s", k, v)
|
8
|
+
end
|
9
|
+
output.join("\n")
|
10
|
+
end
|
data/lib/local_commands/help.rb
CHANGED
@@ -44,7 +44,12 @@ def add_help_commands(broker)
|
|
44
44
|
if command.params.size > 0 then
|
45
45
|
puts "Parameters:"
|
46
46
|
command.params.sort { |a,b| a.name <=> b.name }.each do |param|
|
47
|
-
|
47
|
+
default_value = param.default_value != nil ? " (default: #{param.default_value})" : ''
|
48
|
+
param_name = param.name
|
49
|
+
if param.is_default_param
|
50
|
+
param_name += " *"
|
51
|
+
end
|
52
|
+
puts sprintf(" %-20s %s%s\n", param_name, param.description, default_value)
|
48
53
|
end
|
49
54
|
end
|
50
55
|
puts ""
|
data/lib/rhcp_shell_backend.rb
CHANGED
@@ -7,10 +7,11 @@ require 'local_commands/context'
|
|
7
7
|
require 'local_commands/set_prompt'
|
8
8
|
|
9
9
|
require 'display_types/table'
|
10
|
+
require 'display_types/hash'
|
10
11
|
|
11
12
|
require 'rubygems'
|
12
13
|
require 'rhcp'
|
13
|
-
require 'rhcp/memcached_broker'
|
14
|
+
#require 'rhcp/memcached_broker'
|
14
15
|
|
15
16
|
# This shell presents RHCP commands to the user and handles all the parameter
|
16
17
|
# lookup, validation and command completion stuff
|
@@ -194,6 +195,9 @@ class RHCPShellBackend < ShellBackend
|
|
194
195
|
if command.result_hints[:display_type] == "table"
|
195
196
|
output = format_table_output(command, response)
|
196
197
|
puts output
|
198
|
+
elsif command.result_hints[:display_type] == "hash"
|
199
|
+
output = format_hash_output(command, response)
|
200
|
+
puts output
|
197
201
|
elsif command.result_hints[:display_type] == "list"
|
198
202
|
output = ""
|
199
203
|
response.data.each do |row|
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhcp_shell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 12
|
10
|
+
version: 0.2.12
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Philipp Traeder
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-01-20 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -43,22 +43,22 @@ extensions: []
|
|
43
43
|
extra_rdoc_files: []
|
44
44
|
|
45
45
|
files:
|
46
|
-
- bin/rhcp_shell.log
|
47
46
|
- bin/rhcp_shell
|
48
|
-
- lib/util/colorize.rb
|
49
|
-
- lib/shell_backend.rb
|
50
|
-
- lib/version.rb
|
51
|
-
- lib/rhcp_shell_backend.rb
|
52
47
|
- lib/base_shell.rb
|
53
|
-
- lib/display_types/table.rb
|
54
48
|
- lib/test.log
|
55
|
-
- lib/
|
49
|
+
- lib/shell_backend.rb
|
50
|
+
- lib/rhcp_shell_backend.rb
|
56
51
|
- lib/local_commands/set_prompt.rb
|
57
52
|
- lib/local_commands/help.rb
|
58
|
-
- lib/local_commands/
|
53
|
+
- lib/local_commands/context.rb
|
59
54
|
- lib/local_commands/detail.rb
|
60
|
-
-
|
55
|
+
- lib/local_commands/exit.rb
|
56
|
+
- lib/version.rb
|
57
|
+
- lib/util/colorize.rb
|
58
|
+
- lib/display_types/hash.rb
|
59
|
+
- lib/display_types/table.rb
|
61
60
|
- test/rhcp_shell_backend_test.rb
|
61
|
+
- test/setup_test_registry.rb
|
62
62
|
has_rdoc: true
|
63
63
|
homepage: http://rubyforge.org/projects/rhcp
|
64
64
|
licenses: []
|
data/bin/rhcp_shell.log
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# Logfile created on Sat Jun 25 20:16:10 +0000 2011 by logger.rb/22285
|
2
|
-
D, [2011-06-25T20:16:10.643948 #1686] DEBUG -- : now connecting to http://localhost:42000
|
3
|
-
D, [2011-06-25T20:16:10.644097 #1686] DEBUG -- : connecting to http://localhost:42000
|
4
|
-
D, [2011-06-25T20:16:31.881621 #1688] DEBUG -- : setting http://localhost for hostname
|
5
|
-
D, [2011-06-25T20:16:31.881756 #1688] DEBUG -- : now connecting to http://localhost
|
6
|
-
D, [2011-06-25T20:16:31.881865 #1688] DEBUG -- : connecting to http://localhost
|
7
|
-
E, [2011-06-25T20:16:31.883273 #1688] ERROR -- : cannot connect to 'http://localhost' : got http status code 404
|
8
|
-
D, [2011-06-25T20:16:45.728319 #1690] DEBUG -- : setting http://localhost/rhcp for hostname
|
9
|
-
D, [2011-06-25T20:16:45.728460 #1690] DEBUG -- : now connecting to http://localhost/rhcp
|
10
|
-
D, [2011-06-25T20:16:45.728582 #1690] DEBUG -- : connecting to http://localhost/rhcp
|
11
|
-
E, [2011-06-25T20:16:45.730109 #1690] ERROR -- : cannot connect to 'http://localhost/rhcp' : got http status code 404
|