Class: Harbor::CLI
- Inherits:
-
Thor
show all
- Defined in:
- lib/harbor/cli.rb,
lib/harbor/cli/logs.rb,
lib/harbor/cli/rails.rb,
lib/harbor/cli/deploy.rb,
lib/harbor/cli/promote.rb,
lib/harbor/cli/servers.rb,
lib/harbor/cli/projects.rb,
lib/harbor/cli/mcp_command.rb
Defined Under Namespace
Classes: Deploy, Logs, McpCommand, Projects, Promote, Rails, Servers
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
14
15
16
|
# File 'lib/harbor/cli.rb', line 14
def self.exit_on_failure?
true
end
|
Instance Method Details
#add(name, path) ⇒ Object
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/harbor/cli.rb', line 24
def add(name, path)
config = load_config
dests = options[:destinations]&.split(",")&.map(&:strip)
config.add_project(name, path, destinations: dests, description: options[:description])
say "Added project '#{name}' at #{File.expand_path(path)}", :green
project = config.project(name)
say " Destinations: #{project.destinations.join(', ')}" unless project.destinations.empty?
rescue Harbor::Error => e
say_error e.message
end
|
#audit(project_name = nil) ⇒ Object
114
115
116
|
# File 'lib/harbor/cli.rb', line 114
def audit(project_name = nil)
CLI::Servers.new(options, load_config).audit(project_name)
end
|
#deploy(project_name) ⇒ Object
77
78
79
|
# File 'lib/harbor/cli.rb', line 77
def deploy(project_name)
CLI::Deploy.new(options, load_config).deploy(project_name)
end
|
#details(project_name) ⇒ Object
108
109
110
|
# File 'lib/harbor/cli.rb', line 108
def details(project_name)
CLI::Servers.new(options, load_config).details(project_name)
end
|
#exec_cmd(project_name, *cmd_parts) ⇒ Object
100
101
102
103
|
# File 'lib/harbor/cli.rb', line 100
def exec_cmd(project_name, *cmd_parts)
command = cmd_parts.join(" ")
CLI::Deploy.new(options, load_config).exec_cmd(project_name, command)
end
|
#list ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/harbor/cli.rb', line 45
def list
config = load_config
projects = config.projects
if projects.empty?
say "No projects registered. Run 'harbor add NAME PATH' to add one."
return
end
say "Projects:", :bold
projects.each do |p|
dest_str = p.destinations.empty? ? "" : " (#{p.destinations.join(', ')})"
desc_str = p.description ? " - #{p.description}" : ""
say " #{p.name}#{dest_str}#{desc_str}"
say " #{p.path}", :cyan
end
end
|
#logs(project_name) ⇒ Object
93
94
95
|
# File 'lib/harbor/cli.rb', line 93
def logs(project_name)
CLI::Logs.new(options, load_config).logs(project_name)
end
|
#maintenance(project_name, state) ⇒ Object
132
133
134
|
# File 'lib/harbor/cli.rb', line 132
def maintenance(project_name, state)
CLI::Deploy.new(options, load_config).maintenance(project_name, state)
end
|
#mcp ⇒ Object
137
138
139
|
# File 'lib/harbor/cli.rb', line 137
def mcp
CLI::McpCommand.new(options, load_config).start
end
|
144
145
146
147
|
# File 'lib/harbor/cli.rb', line 144
def promote
exit_code = CLI::Promote.new(options.transform_keys(&:to_sym)).run
exit(exit_code) if exit_code != 0
end
|
#rails(project_name, subcommand, *args) ⇒ Object
126
127
128
|
# File 'lib/harbor/cli.rb', line 126
def rails(project_name, subcommand, *args)
CLI::Rails.new(options, load_config).run(project_name, subcommand, args)
end
|
#remove(name) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/harbor/cli.rb', line 36
def remove(name)
config = load_config
config.remove_project(name)
say "Removed project '#{name}'", :green
rescue Harbor::Error => e
say_error e.message
end
|
#rollback(project_name, version) ⇒ Object
83
84
85
|
# File 'lib/harbor/cli.rb', line 83
def rollback(project_name, version)
CLI::Deploy.new(options, load_config).rollback(project_name, version)
end
|
#runner(project_name, script) ⇒ Object
120
121
122
|
# File 'lib/harbor/cli.rb', line 120
def runner(project_name, script)
CLI::Rails.new(options, load_config).run(project_name, "runner", [script])
end
|
#status(project_name = nil) ⇒ Object
70
71
72
|
# File 'lib/harbor/cli.rb', line 70
def status(project_name = nil)
CLI::Servers.new(options, load_config).status(project_name)
end
|