Class: SchwarmCli::Commands::Repos
- Inherits:
-
Base
- Object
- Thor
- Base
- SchwarmCli::Commands::Repos
show all
- Defined in:
- lib/schwarm_cli/commands/repos.rb
Constant Summary
Constants inherited
from Base
Base::DEFAULT_LIST_LIMIT
Instance Method Summary
collapse
Methods inherited from Base
exit_on_failure?, pagination_options
Instance Method Details
#create ⇒ Object
34
35
36
37
38
39
|
# File 'lib/schwarm_cli/commands/repos.rb', line 34
def create
handle_errors do
data = client.repositories.create(**create_attrs)
output_record(data, fields: { "ID" => "id", "Name" => "name", "Status" => "status" })
end
end
|
#delete(id) ⇒ Object
56
57
58
59
60
61
|
# File 'lib/schwarm_cli/commands/repos.rb', line 56
def delete(id)
handle_errors do
client.repositories.destroy(id)
puts "Repository #{id} deleted."
end
end
|
#list ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/schwarm_cli/commands/repos.rb', line 10
def list
handle_errors do
data = fetch_paged do |page_params|
client.repositories.list(status: options[:status], query: options[:query], **page_params)
end
output_list(data, columns: [%w[ID id], %w[NAME name], %w[STATUS status]])
end
end
|
#pause(id) ⇒ Object
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/schwarm_cli/commands/repos.rb', line 64
def pause(id)
handle_errors do
data = client.repositories.pause(id)
if options[:json]
output_record(data, fields: {})
else
puts "Repository #{id} paused (#{data.dig('data', 'status')})."
end
end
end
|
#resume(id) ⇒ Object
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/schwarm_cli/commands/repos.rb', line 76
def resume(id)
handle_errors do
data = client.repositories.resume(id)
if options[:json]
output_record(data, fields: {})
else
puts "Repository #{id} resumed (#{data.dig('data', 'status')})."
end
end
end
|
#show(id) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/schwarm_cli/commands/repos.rb', line 20
def show(id)
handle_errors do
data = client.repositories.find(id)
output_record(data, fields: {
"ID" => "id", "Name" => "name", "URL" => "url",
"Status" => "status", "Base Branch" => "base_branch"
})
end
end
|
#update(id) ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/schwarm_cli/commands/repos.rb', line 44
def update(id)
handle_errors do
attrs = {}
attrs[:name] = options[:name] if options[:name]
attrs[:base_branch] = options[:base_branch] if options[:base_branch]
data = client.repositories.update(id, **attrs)
output_record(data, fields: { "ID" => "id", "Name" => "name", "Status" => "status" })
end
end
|