Class: OSDN::CLI::Command::Release
Instance Attribute Summary
Attributes inherited from Base
#credential, #format, #logger
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from FrsBase
#run
Methods inherited from Base
#credential_path, #initialize, #load_credential, #load_variables, #set_client_token, #set_credential, #update_token, #update_variables, #write_credential, #write_variables
Class Method Details
.description ⇒ Object
17
18
19
|
# File 'lib/osdn/cli/command/release.rb', line 17
def self.description
"Manipulate frs releases of project"
end
|
Instance Method Details
#_set_release_id ⇒ Object
94
95
96
97
|
# File 'lib/osdn/cli/command/release.rb', line 94
def _set_release_id
return if ARGV[0].to_i == 0
@target_release = ARGV[0].to_i
end
|
#create ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/osdn/cli/command/release.rb', line 61
def create
name = ARGV.shift
if !name
logger.fatal "Release name is missing."
help
return
end
r = api.create_release target_proj, target_package, name, visibility: @visibility
logger.info "New release has been created."
puts format_release(r)
end
|
#delete ⇒ Object
88
89
90
91
92
|
# File 'lib/osdn/cli/command/release.rb', line 88
def delete
_set_release_id
r = api.delete_release target_proj, target_package, target_release
logger.info "Release #{target_release} has been deleted."
end
|
#help ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/osdn/cli/command/release.rb', line 5
def help
puts "#{$0} release [opts] [list]"
puts "#{$0} release [opts] create <new-release-name>"
puts "#{$0} release [opts] update [numeric-release-id] [name]"
puts "#{$0} release [opts] delete [numeric-release-id]"
puts "Options:"
puts " -f --format=<pretty|json> Set output format"
puts " -p --project=<project> Target project (numeric id or name)"
puts " --package=<package-id> Target package (numeric id)"
puts " -v --visibility=<public|private|hidden>"
end
|
#list ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/osdn/cli/command/release.rb', line 49
def list
package = api.get_package target_proj, target_package
list = package.releases
if format == 'json'
puts list.map{|i| i.to_hash}.to_json
else
list.each do |r|
puts format_release(r)
end
end
end
|
#process_options ⇒ Object
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
|
# File 'lib/osdn/cli/command/release.rb', line 21
def process_options
opts = GetoptLong.new(
[ '--format', '-f', GetoptLong::REQUIRED_ARGUMENT ],
[ '--project', '-p', GetoptLong::REQUIRED_ARGUMENT ],
[ '--package', GetoptLong::REQUIRED_ARGUMENT ],
[ '--visibility', '-v', GetoptLong::REQUIRED_ARGUMENT ],
)
opts.each do |opt, arg|
case opt
when '--format'
arg == 'json' and
self.format = arg
when '--project'
arg.empty? or
@target_proj = arg
when '--package'
arg.empty? or
@target_package = arg
when '--visibility'
unless %w(public private hidden).member?(arg)
logger.fatal "Invalid visibility status: #{arg}"
exit
end
@visibility = arg
end
end
end
|
#update ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/osdn/cli/command/release.rb', line 73
def update
_set_release_id
args = {}
if ARGV[1].to_s != ""
args[:name] = ARGV.shift
end
if @visibility
args[:visibility] = @visibility
end
logger.debug "Updating release #{target_release} as #{args.inspect}"
r = api.update_release target_proj, target_package, target_release, args
logger.info "Release #{target_release} has been updated."
puts format_release(r)
end
|