hmx_client 0.0.7 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -4
- data/Gemfile +4 -4
- data/Rakefile +1 -1
- data/bin/hmx +33 -33
- data/hmx_client.gemspec +27 -27
- data/lib/hmx/client.rb +167 -167
- data/lib/hmx/command.rb +140 -140
- data/lib/hmx/command/base.rb +195 -194
- data/lib/hmx/command/bootstrap.rb +18 -18
- data/lib/hmx/command/check.rb +170 -0
- data/lib/hmx/command/clone.rb +77 -77
- data/lib/hmx/command/config.rb +67 -67
- data/lib/hmx/command/dump.rb +67 -67
- data/lib/hmx/command/fn.rb +125 -43
- data/lib/hmx/command/fountain.rb +46 -46
- data/lib/hmx/command/get.rb +20 -20
- data/lib/hmx/command/getContent.rb +20 -20
- data/lib/hmx/command/help.rb +114 -114
- data/lib/hmx/command/partition.rb +38 -38
- data/lib/hmx/command/query.rb +22 -22
- data/lib/hmx/command/session.rb +35 -35
- data/lib/hmx/command/task.rb +32 -32
- data/lib/hmx/command/type.rb +45 -45
- data/lib/hmx/command/user.rb +68 -68
- data/lib/hmx/command/view.rb +161 -155
- data/lib/hmx/helpers.rb +76 -61
- data/lib/hmx/hmx.rb +148 -215
- data/lib/hmx/version.rb +3 -3
- data/lib/hmx_client.rb +7 -7
- data/sampleCommands.txt +5 -5
- metadata +12 -11
data/lib/hmx/command/help.rb
CHANGED
@@ -1,114 +1,114 @@
|
|
1
|
-
require "hmx/command/base"
|
2
|
-
|
3
|
-
# list commands and display help
|
4
|
-
#
|
5
|
-
class HmxClient::Command::Help < HmxClient::Command::Base
|
6
|
-
|
7
|
-
PRIMARY_NAMESPACES = %w( config query get view)
|
8
|
-
|
9
|
-
# help [COMMAND]
|
10
|
-
#
|
11
|
-
# list available commands or display help for a specific command
|
12
|
-
#
|
13
|
-
def index
|
14
|
-
if command = args.shift
|
15
|
-
help_for_command(command)
|
16
|
-
else
|
17
|
-
help_for_root
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
alias_command "-h", "help"
|
22
|
-
alias_command "--help", "help"
|
23
|
-
|
24
|
-
def self.usage_for_command(command)
|
25
|
-
command = new.send(:commands)[command]
|
26
|
-
"Usage: hmx #{command[:banner]}" if command
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def commands_for_namespace(name)
|
32
|
-
HmxClient::Command.commands.values.select do |command|
|
33
|
-
command[:namespace] == name && command[:command] != name
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def namespaces
|
38
|
-
namespaces = HmxClient::Command.namespaces
|
39
|
-
namespaces
|
40
|
-
end
|
41
|
-
|
42
|
-
def commands
|
43
|
-
commands = HmxClient::Command.commands
|
44
|
-
HmxClient::Command.command_aliases.each do |new, old|
|
45
|
-
commands[new] = commands[old].dup
|
46
|
-
commands[new][:banner] = "#{new} #{commands[new][:banner].split(" ", 2)[1]}"
|
47
|
-
commands[new][:command] = new
|
48
|
-
commands[new][:namespace] = nil
|
49
|
-
end
|
50
|
-
commands
|
51
|
-
end
|
52
|
-
|
53
|
-
def primary_namespaces
|
54
|
-
PRIMARY_NAMESPACES.map { |name| namespaces[name] }.compact
|
55
|
-
end
|
56
|
-
|
57
|
-
def additional_namespaces
|
58
|
-
(namespaces.values - primary_namespaces).sort_by { |n| n[:name] }
|
59
|
-
end
|
60
|
-
|
61
|
-
def summary_for_namespaces(namespaces)
|
62
|
-
size = longest(namespaces.map { |n| n[:name] })
|
63
|
-
namespaces.each do |namespace|
|
64
|
-
name = namespace[:name]
|
65
|
-
namespace[:description] ||= legacy_help_for_namespace(name)
|
66
|
-
puts " %-#{size}s # %s" % [ name, namespace[:description] ]
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def help_for_root
|
71
|
-
puts "Usage: hmx COMMAND [command-specific-options]"
|
72
|
-
puts
|
73
|
-
puts "Primary help topics, type \"hmx help TOPIC\" for more details:"
|
74
|
-
puts
|
75
|
-
summary_for_namespaces(primary_namespaces)
|
76
|
-
puts
|
77
|
-
puts "Additional topics:"
|
78
|
-
puts
|
79
|
-
summary_for_namespaces(additional_namespaces)
|
80
|
-
puts
|
81
|
-
end
|
82
|
-
|
83
|
-
def help_for_namespace(name)
|
84
|
-
namespace_commands = commands_for_namespace(name)
|
85
|
-
|
86
|
-
unless namespace_commands.empty?
|
87
|
-
size = longest(namespace_commands.map { |c| c[:banner] })
|
88
|
-
namespace_commands.sort_by { |c| c[:banner].to_s }.each do |command|
|
89
|
-
next if command[:help] =~ /DEPRECATED/
|
90
|
-
command[:summary] ||= legacy_help_for_command(command[:command])
|
91
|
-
puts " %-#{size}s # %s" % [ command[:banner], command[:summary] ]
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def help_for_command(name)
|
97
|
-
command = commands[name]
|
98
|
-
|
99
|
-
if command
|
100
|
-
if command[:help].strip.length > 0
|
101
|
-
puts "Usage: hmx #{command[:banner]}"
|
102
|
-
puts command[:help].split("\n")[1..-1].join("\n")
|
103
|
-
puts
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
unless commands_for_namespace(name).empty?
|
108
|
-
puts "Additional commands, type \"hmx help COMMAND\" for more details:"
|
109
|
-
puts
|
110
|
-
help_for_namespace(name)
|
111
|
-
puts
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
1
|
+
require "hmx/command/base"
|
2
|
+
|
3
|
+
# list commands and display help
|
4
|
+
#
|
5
|
+
class HmxClient::Command::Help < HmxClient::Command::Base
|
6
|
+
|
7
|
+
PRIMARY_NAMESPACES = %w( config query get view)
|
8
|
+
|
9
|
+
# help [COMMAND]
|
10
|
+
#
|
11
|
+
# list available commands or display help for a specific command
|
12
|
+
#
|
13
|
+
def index
|
14
|
+
if command = args.shift
|
15
|
+
help_for_command(command)
|
16
|
+
else
|
17
|
+
help_for_root
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
alias_command "-h", "help"
|
22
|
+
alias_command "--help", "help"
|
23
|
+
|
24
|
+
def self.usage_for_command(command)
|
25
|
+
command = new.send(:commands)[command]
|
26
|
+
"Usage: hmx #{command[:banner]}" if command
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def commands_for_namespace(name)
|
32
|
+
HmxClient::Command.commands.values.select do |command|
|
33
|
+
command[:namespace] == name && command[:command] != name
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def namespaces
|
38
|
+
namespaces = HmxClient::Command.namespaces
|
39
|
+
namespaces
|
40
|
+
end
|
41
|
+
|
42
|
+
def commands
|
43
|
+
commands = HmxClient::Command.commands
|
44
|
+
HmxClient::Command.command_aliases.each do |new, old|
|
45
|
+
commands[new] = commands[old].dup
|
46
|
+
commands[new][:banner] = "#{new} #{commands[new][:banner].split(" ", 2)[1]}"
|
47
|
+
commands[new][:command] = new
|
48
|
+
commands[new][:namespace] = nil
|
49
|
+
end
|
50
|
+
commands
|
51
|
+
end
|
52
|
+
|
53
|
+
def primary_namespaces
|
54
|
+
PRIMARY_NAMESPACES.map { |name| namespaces[name] }.compact
|
55
|
+
end
|
56
|
+
|
57
|
+
def additional_namespaces
|
58
|
+
(namespaces.values - primary_namespaces).sort_by { |n| n[:name] }
|
59
|
+
end
|
60
|
+
|
61
|
+
def summary_for_namespaces(namespaces)
|
62
|
+
size = longest(namespaces.map { |n| n[:name] })
|
63
|
+
namespaces.each do |namespace|
|
64
|
+
name = namespace[:name]
|
65
|
+
namespace[:description] ||= legacy_help_for_namespace(name)
|
66
|
+
puts " %-#{size}s # %s" % [ name, namespace[:description] ]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def help_for_root
|
71
|
+
puts "Usage: hmx COMMAND [command-specific-options]"
|
72
|
+
puts
|
73
|
+
puts "Primary help topics, type \"hmx help TOPIC\" for more details:"
|
74
|
+
puts
|
75
|
+
summary_for_namespaces(primary_namespaces)
|
76
|
+
puts
|
77
|
+
puts "Additional topics:"
|
78
|
+
puts
|
79
|
+
summary_for_namespaces(additional_namespaces)
|
80
|
+
puts
|
81
|
+
end
|
82
|
+
|
83
|
+
def help_for_namespace(name)
|
84
|
+
namespace_commands = commands_for_namespace(name)
|
85
|
+
|
86
|
+
unless namespace_commands.empty?
|
87
|
+
size = longest(namespace_commands.map { |c| c[:banner] })
|
88
|
+
namespace_commands.sort_by { |c| c[:banner].to_s }.each do |command|
|
89
|
+
next if command[:help] =~ /DEPRECATED/
|
90
|
+
command[:summary] ||= legacy_help_for_command(command[:command])
|
91
|
+
puts " %-#{size}s # %s" % [ command[:banner], command[:summary] ]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def help_for_command(name)
|
97
|
+
command = commands[name]
|
98
|
+
|
99
|
+
if command
|
100
|
+
if command[:help].strip.length > 0
|
101
|
+
puts "Usage: hmx #{command[:banner]}"
|
102
|
+
puts command[:help].split("\n")[1..-1].join("\n")
|
103
|
+
puts
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
unless commands_for_namespace(name).empty?
|
108
|
+
puts "Additional commands, type \"hmx help COMMAND\" for more details:"
|
109
|
+
puts
|
110
|
+
help_for_namespace(name)
|
111
|
+
puts
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -1,38 +1,38 @@
|
|
1
|
-
require "hmx/command/base"
|
2
|
-
require 'date'
|
3
|
-
|
4
|
-
module HmxClient::Command
|
5
|
-
|
6
|
-
# Create new partitions in HMX based on the current partition
|
7
|
-
#
|
8
|
-
class Partition < Base
|
9
|
-
|
10
|
-
# partition
|
11
|
-
#
|
12
|
-
# List the partitions on this system (requires administrative privileges)
|
13
|
-
def index
|
14
|
-
partitions = hmx.
|
15
|
-
partitions.each do | p |
|
16
|
-
puts p['name'];
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# partition:create
|
21
|
-
#
|
22
|
-
# Create a new partition based on this partition
|
23
|
-
def create
|
24
|
-
target = args.shift;
|
25
|
-
style = args.shift;
|
26
|
-
partition = hmx.
|
27
|
-
end
|
28
|
-
|
29
|
-
# partition:switch
|
30
|
-
#
|
31
|
-
# Switch the context of this hmx configuration to a new partition
|
32
|
-
# This is basically a synonym of config:add partition=[partition]
|
33
|
-
def switch
|
34
|
-
storeConfig("partition".to_sym, args.shift);
|
35
|
-
puts "Done"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
1
|
+
require "hmx/command/base"
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
module HmxClient::Command
|
5
|
+
|
6
|
+
# Create new partitions in HMX based on the current partition
|
7
|
+
#
|
8
|
+
class Partition < Base
|
9
|
+
|
10
|
+
# partition
|
11
|
+
#
|
12
|
+
# List the partitions on this system (requires administrative privileges)
|
13
|
+
def index
|
14
|
+
partitions = hmx.doGetPartitions([]);
|
15
|
+
partitions.each do | p |
|
16
|
+
puts p['name'];
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# partition:create
|
21
|
+
#
|
22
|
+
# Create a new partition based on this partition
|
23
|
+
def create
|
24
|
+
target = args.shift;
|
25
|
+
style = args.shift;
|
26
|
+
partition = hmx.doClonePartition([target, style]);
|
27
|
+
end
|
28
|
+
|
29
|
+
# partition:switch
|
30
|
+
#
|
31
|
+
# Switch the context of this hmx configuration to a new partition
|
32
|
+
# This is basically a synonym of config:add partition=[partition]
|
33
|
+
def switch
|
34
|
+
storeConfig("partition".to_sym, args.shift);
|
35
|
+
puts "Done"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/hmx/command/query.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
require "hmx/command/base"
|
2
|
-
|
3
|
-
module HmxClient::Command
|
4
|
-
|
5
|
-
# Perform queries against data in hmx
|
6
|
-
#
|
7
|
-
class Query < Base
|
8
|
-
|
9
|
-
# query
|
10
|
-
#
|
11
|
-
# query for documents in a type
|
12
|
-
#
|
13
|
-
# TYPENAME
|
14
|
-
#
|
15
|
-
def index
|
16
|
-
unless args.size > 0
|
17
|
-
raise CommandFailed, "Usage: hmx query <typeName> [<key>=<value>, [<key2>=<value2>...]]"
|
18
|
-
end
|
19
|
-
display hmx.
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
1
|
+
require "hmx/command/base"
|
2
|
+
|
3
|
+
module HmxClient::Command
|
4
|
+
|
5
|
+
# Perform queries against data in hmx
|
6
|
+
#
|
7
|
+
class Query < Base
|
8
|
+
|
9
|
+
# query
|
10
|
+
#
|
11
|
+
# query for documents in a type
|
12
|
+
#
|
13
|
+
# TYPENAME
|
14
|
+
#
|
15
|
+
def index
|
16
|
+
unless args.size > 0
|
17
|
+
raise CommandFailed, "Usage: hmx query <typeName> [<key>=<value>, [<key2>=<value2>...]]"
|
18
|
+
end
|
19
|
+
display hmx.doQuery([args.shift, nil])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/hmx/command/session.rb
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
require "hmx/command/base"
|
2
|
-
require 'date'
|
3
|
-
|
4
|
-
module HmxClient::Command
|
5
|
-
|
6
|
-
# Display and manage session information for hmx
|
7
|
-
#
|
8
|
-
class Session < Base
|
9
|
-
|
10
|
-
# session
|
11
|
-
#
|
12
|
-
# List the sessions and their status on hmx
|
13
|
-
def index
|
14
|
-
displayNames = hmx.
|
15
|
-
objs = []
|
16
|
-
displayNames.each do | name |
|
17
|
-
data = hmx.
|
18
|
-
dval = JSON.parse(data)
|
19
|
-
dval["MXSession"]["validUntil"] = Time.at(dval["MXSession"]["validUntil"] / 1000).to_datetime.strftime
|
20
|
-
objs << dval["MXSession"]
|
21
|
-
end
|
22
|
-
cols = [ 'sessionId', 'userId', 'authenticated','validUntil' ]
|
23
|
-
headers = [ 'Session', 'Username', 'Authenticated', 'ValidUntil' ]
|
24
|
-
display_table(objs, cols, headers)
|
25
|
-
end
|
26
|
-
|
27
|
-
# session:expire
|
28
|
-
#
|
29
|
-
# Forces the expiry of any old sessions
|
30
|
-
#
|
31
|
-
def expire
|
32
|
-
display hmx.
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
1
|
+
require "hmx/command/base"
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
module HmxClient::Command
|
5
|
+
|
6
|
+
# Display and manage session information for hmx
|
7
|
+
#
|
8
|
+
class Session < Base
|
9
|
+
|
10
|
+
# session
|
11
|
+
#
|
12
|
+
# List the sessions and their status on hmx
|
13
|
+
def index
|
14
|
+
displayNames = hmx.doQuery(['sys.session', nil])
|
15
|
+
objs = []
|
16
|
+
displayNames.each do | name |
|
17
|
+
data = hmx.doGetContent([name])
|
18
|
+
dval = JSON.parse(data)
|
19
|
+
dval["MXSession"]["validUntil"] = Time.at(dval["MXSession"]["validUntil"] / 1000).to_datetime.strftime
|
20
|
+
objs << dval["MXSession"]
|
21
|
+
end
|
22
|
+
cols = [ 'sessionId', 'userId', 'authenticated','validUntil' ]
|
23
|
+
headers = [ 'Session', 'Username', 'Authenticated', 'ValidUntil' ]
|
24
|
+
display_table(objs, cols, headers)
|
25
|
+
end
|
26
|
+
|
27
|
+
# session:expire
|
28
|
+
#
|
29
|
+
# Forces the expiry of any old sessions
|
30
|
+
#
|
31
|
+
def expire
|
32
|
+
display hmx.doExpireSessions([])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/hmx/command/task.rb
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
require "hmx/command/base"
|
2
|
-
require 'date'
|
3
|
-
|
4
|
-
module HmxClient::Command
|
5
|
-
|
6
|
-
# Display and manage tasks in hmx
|
7
|
-
#
|
8
|
-
class Task < Base
|
9
|
-
|
10
|
-
# task
|
11
|
-
#
|
12
|
-
# List all of the tasks
|
13
|
-
def index
|
14
|
-
tasks = hmx.
|
15
|
-
objs = []
|
16
|
-
tasks.each do | t |
|
17
|
-
task = hmx.
|
18
|
-
objs << task
|
19
|
-
end
|
20
|
-
headers = [ "TaskId", "TaskType", "TaskState", "GroupId" ]
|
21
|
-
cols = [ "taskId", "taskType", "taskState", "group" ]
|
22
|
-
display_table(objs, cols, headers)
|
23
|
-
end
|
24
|
-
# task:purge
|
25
|
-
#
|
26
|
-
# Purge completed tasks
|
27
|
-
def purge
|
28
|
-
hmx.
|
29
|
-
display "Purge complete"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
1
|
+
require "hmx/command/base"
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
module HmxClient::Command
|
5
|
+
|
6
|
+
# Display and manage tasks in hmx
|
7
|
+
#
|
8
|
+
class Task < Base
|
9
|
+
|
10
|
+
# task
|
11
|
+
#
|
12
|
+
# List all of the tasks
|
13
|
+
def index
|
14
|
+
tasks = hmx.doGetAllTasks([])
|
15
|
+
objs = []
|
16
|
+
tasks.each do | t |
|
17
|
+
task = hmx.doGetTask([t])
|
18
|
+
objs << task
|
19
|
+
end
|
20
|
+
headers = [ "TaskId", "TaskType", "TaskState", "GroupId" ]
|
21
|
+
cols = [ "taskId", "taskType", "taskState", "group" ]
|
22
|
+
display_table(objs, cols, headers)
|
23
|
+
end
|
24
|
+
# task:purge
|
25
|
+
#
|
26
|
+
# Purge completed tasks
|
27
|
+
def purge
|
28
|
+
hmx.doPurgeTasks([])
|
29
|
+
display "Purge complete"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|