Class: LanguageOperator::CLI::Formatters::TableFormatter
- Inherits:
-
Object
- Object
- LanguageOperator::CLI::Formatters::TableFormatter
show all
- Extended by:
- Helpers::UxHelper
- Defined in:
- lib/language_operator/cli/formatters/table_formatter.rb
Overview
Table output for CLI list commands
Class Method Summary
collapse
box, highlight_ruby_code, logo, pastel, prompt, spinner, table
Class Method Details
.agents(agents) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/language_operator/cli/formatters/table_formatter.rb', line 52
def agents(agents)
return ProgressFormatter.info('No agents found') if agents.empty?
= ['', 'NAME', 'NAMESPACE', 'STATUS', 'MODE']
rows = agents.map do |agent|
[
StatusFormatter.dot(agent[:status]),
agent[:name],
agent[:namespace],
agent[:status] || 'Unknown',
agent[:mode]
]
end
puts table(, rows)
end
|
.all_agents(agents_by_cluster) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/language_operator/cli/formatters/table_formatter.rb', line 69
def all_agents(agents_by_cluster)
return ProgressFormatter.info('No agents found across any cluster') if agents_by_cluster.empty?
= ['CLUSTER', 'NAME', 'MODE', 'STATUS', 'NEXT RUN', 'EXECUTIONS']
rows = []
agents_by_cluster.each do |cluster_name, agents|
agents.each do |agent|
rows << [
cluster_name,
agent[:name],
agent[:mode],
StatusFormatter.format(agent[:status]),
agent[:next_run] || 'N/A',
agent[:executions] || 0
]
end
end
puts table(, rows)
end
|
.clusters(clusters) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/language_operator/cli/formatters/table_formatter.rb', line 14
def clusters(clusters)
return ProgressFormatter.info('No clusters found') if clusters.empty?
= ['', 'NAME', 'NAMESPACE', 'ORGANIZATION', 'STATUS', 'DOMAIN']
rows = clusters.map do |cluster|
name = cluster[:name].to_s.gsub(' *', '')
is_current = cluster[:name].to_s.include?(' *')
formatted_name = is_current ? pastel.bold.yellow(name) : name
domain_display = case cluster[:domain]
when nil, ''
''
when '?', '-'
cluster[:domain]
else
cluster[:domain]
end
org_display = cluster[:organization] || 'legacy'
[
StatusFormatter.dot(cluster[:status] || 'Unknown'),
formatted_name,
cluster[:namespace],
org_display,
cluster[:status] || 'Unknown',
domain_display
]
end
puts table(, rows)
end
|
.models(models) ⇒ Object
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/language_operator/cli/formatters/table_formatter.rb', line 123
def models(models)
return ProgressFormatter.info('No models found') if models.empty?
= ['', 'NAME', 'NAMESPACE', 'STATUS', 'PROVIDER/MODEL']
rows = models.map do |model|
provider_model = "#{model[:provider]}/#{model[:model]}"
[
StatusFormatter.dot(model[:status]),
model[:name],
model[:namespace],
model[:status] || 'Unknown',
provider_model
]
end
puts table(, rows)
end
|
.organizations(organizations) ⇒ Object
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
# File 'lib/language_operator/cli/formatters/table_formatter.rb', line 167
def organizations(organizations)
return ProgressFormatter.info('No organizations found') if organizations.empty?
= ['NAMESPACE', 'ORGANIZATION ID', 'PLAN', 'CREATED']
rows = organizations.map do |org|
[
org[:namespace],
org[:organization_id],
org[:plan],
org[:created]
]
end
puts table(, rows)
end
|
.personas(personas) ⇒ Object
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/language_operator/cli/formatters/table_formatter.rb', line 107
def personas(personas)
return ProgressFormatter.info('No personas found') if personas.empty?
= ['NAME', 'TONE', 'USED BY', 'DESCRIPTION']
rows = personas.map do |persona|
[
persona[:name],
persona[:tone],
persona[:used_by] || 0,
truncate(persona[:description], 50)
]
end
puts table(, rows)
end
|
.status_dashboard(cluster_summary, current_cluster: nil) ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
# File 'lib/language_operator/cli/formatters/table_formatter.rb', line 142
def status_dashboard(cluster_summary, current_cluster: nil)
return ProgressFormatter.info('No clusters configured') if cluster_summary.empty?
= %w[CLUSTER AGENTS TOOLS MODELS STATUS]
rows = cluster_summary.map do |cluster|
name = cluster[:name].to_s
name += ' *' if current_cluster && cluster[:name] == current_cluster
[
name,
cluster[:agents] || 0,
cluster[:tools] || 0,
cluster[:models] || 0,
StatusFormatter.format(cluster[:status] || 'Unknown')
]
end
puts table(, rows)
return unless current_cluster
puts
puts '* = current cluster'
end
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/language_operator/cli/formatters/table_formatter.rb', line 91
def tools(tools)
return ProgressFormatter.info('No tools found') if tools.empty?
= ['', 'NAME', 'NAMESPACE', 'STATUS']
rows = tools.map do |tool|
[
StatusFormatter.dot(tool[:status]),
tool[:name],
tool[:namespace],
tool[:status] || 'Unknown'
]
end
puts table(, rows)
end
|