Class: LanguageOperator::CLI::Main
- Inherits:
-
Thor
- Object
- Thor
- LanguageOperator::CLI::Main
show all
- Includes:
- Helpers::UxHelper
- Defined in:
- lib/language_operator/cli/main.rb
Overview
Main CLI class for langop command
Provides commands for creating, running, and managing language-operator resources.
Class Method Summary
collapse
Instance Method Summary
collapse
#box, #highlight_ruby_code, #logo, #pastel, #prompt, #spinner, #table
Class Method Details
.exit_on_failure? ⇒ Boolean
31
32
33
|
# File 'lib/language_operator/cli/main.rb', line 31
def self.exit_on_failure?
true
end
|
Instance Method Details
#completion(shell) ⇒ Object
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
# File 'lib/language_operator/cli/main.rb', line 159
def completion(shell)
case shell.downcase
when 'bash'
install_bash_completion
when 'zsh'
install_zsh_completion
when 'fish'
install_fish_completion
else
message = "Unsupported shell: #{shell}"
Formatters::ProgressFormatter.error(message)
puts
puts 'Supported shells: bash, zsh, fish'
raise Errors::ValidationError, message
end
end
|
#help(command = nil, subcommand = false) ⇒ Object
176
177
178
179
180
181
182
183
184
|
# File 'lib/language_operator/cli/main.rb', line 176
def help(command = nil, subcommand = false)
if command.nil? && !subcommand
logo
end
super
end
|
#install ⇒ Object
116
117
118
|
# File 'lib/language_operator/cli/main.rb', line 116
def install
Commands::Install.new([], options).install
end
|
#status ⇒ Object
36
37
38
|
# File 'lib/language_operator/cli/main.rb', line 36
def status
Commands::Status.new.invoke(:overview)
end
|
#ui ⇒ Object
104
105
106
|
# File 'lib/language_operator/cli/main.rb', line 104
def ui
Commands::Ui.new([], options).ui
end
|
#uninstall ⇒ Object
135
136
137
|
# File 'lib/language_operator/cli/main.rb', line 135
def uninstall
Commands::Install.new([], options).uninstall
end
|
#upgrade ⇒ Object
127
128
129
|
# File 'lib/language_operator/cli/main.rb', line 127
def upgrade
Commands::Install.new([], options).upgrade
end
|
#use(cluster_name) ⇒ Object
79
80
81
|
# File 'lib/language_operator/cli/main.rb', line 79
def use(cluster_name)
Commands::Use.new.switch(cluster_name)
end
|
#version ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/language_operator/cli/main.rb', line 41
def version
current_cluster = Config::ClusterConfig.current_cluster
operator_version = nil
operator_installed = false
if current_cluster
cluster_config = Config::ClusterConfig.get_cluster(current_cluster)
begin
k8s = Kubernetes::Client.new(
kubeconfig: cluster_config[:kubeconfig],
context: cluster_config[:context]
)
if k8s.operator_installed?
operator_installed = true
operator_version = k8s.operator_version || 'unknown'
end
rescue StandardError
end
end
if operator_installed
logo(sparkle: true, title: "kubernetes language-operator detected (v#{operator_version})")
else
logo(sparkle: true, title: 'kubernetes language-operator not found')
end
end
|