修訂 | 9ffb4d214856f039b9177b3fad8a1160fe528fcc (tree) |
---|---|
時間 | 2018-10-29 19:28:41 |
作者 | Tatsuki Sugiura <sugi@nemu...> |
Commiter | Tatsuki Sugiura |
Package and release command gets target from vars file.
@@ -5,8 +5,8 @@ module OSDN; module CLI; module Command | ||
5 | 5 | def help |
6 | 6 | puts "#{$0} package [opts] [list]" |
7 | 7 | puts "#{$0} package [opts] create <new-package-name>" |
8 | - puts "#{$0} package [opts] update <numeric-package-id> [name]" | |
9 | - puts "#{$0} package [opts] delete <numeric-package-id>" | |
8 | + puts "#{$0} package [opts] update [numeric-package-id] [name]" | |
9 | + puts "#{$0} package [opts] delete [numeric-package-id]" | |
10 | 10 | puts "Options:" |
11 | 11 | puts " -f --format=<pretty|json> Set output format" |
12 | 12 | puts " -p --project=<project> Target project (numeric id or name)" |
@@ -65,20 +65,29 @@ module OSDN; module CLI; module Command | ||
65 | 65 | end |
66 | 66 | |
67 | 67 | def update |
68 | - target_id = ARGV.shift | |
69 | - args = {name: ARGV.shift} | |
68 | + _set_package_id | |
69 | + args = {} | |
70 | + if ARGV[1].to_s != "" | |
71 | + args[:name] = ARGV[1] | |
72 | + end | |
70 | 73 | if @visibility |
71 | 74 | args[:visibility] = @visibility |
72 | 75 | end |
73 | - p = api.update_package target_proj, target_id, args | |
74 | - logger.info "Package #{target_id} has been updated." | |
76 | + logger.debug "Updating package #{target_package} as #{args.inspect}" | |
77 | + p = api.update_package target_proj, target_package, args | |
78 | + logger.info "Package #{target_package} has been updated." | |
75 | 79 | puts format_package(p) |
76 | 80 | end |
77 | 81 | |
78 | 82 | def delete |
79 | - target_id = ARGV.shift | |
80 | - p = api.delete_package target_proj, target_id | |
81 | - logger.info "Package #{target_id} has been deleted." | |
83 | + _set_package_id | |
84 | + p = api.delete_package target_proj, target_package | |
85 | + logger.info "Package #{target_package} has been deleted." | |
86 | + end | |
87 | + | |
88 | + def _set_package_id | |
89 | + return if ARGV[0].to_i == 0 | |
90 | + @target_package = ARGV[0].to_i | |
82 | 91 | end |
83 | 92 | |
84 | 93 | end |
@@ -5,8 +5,8 @@ module OSDN; module CLI; module Command | ||
5 | 5 | def help |
6 | 6 | puts "#{$0} release [opts] [list]" |
7 | 7 | puts "#{$0} release [opts] create <new-release-name>" |
8 | - puts "#{$0} release [opts] update <numeric-release-id> [name]" | |
9 | - puts "#{$0} release [opts] delete <numeric-release-id>" | |
8 | + puts "#{$0} release [opts] update [numeric-release-id] [name]" | |
9 | + puts "#{$0} release [opts] delete [numeric-release-id]" | |
10 | 10 | puts "Options:" |
11 | 11 | puts " -f --format=<pretty|json> Set output format" |
12 | 12 | puts " -p --project=<project> Target project (numeric id or name)" |
@@ -71,21 +71,29 @@ module OSDN; module CLI; module Command | ||
71 | 71 | end |
72 | 72 | |
73 | 73 | def update |
74 | - target_id = ARGV.shift | |
75 | - args = {name: ARGV.shift} | |
74 | + _set_release_id | |
75 | + args = {} | |
76 | + if ARGV[1].to_s != "" | |
77 | + args[:name] = ARGV.shift | |
78 | + end | |
76 | 79 | if @visibility |
77 | 80 | args[:visibility] = @visibility |
78 | 81 | end |
79 | - r = api.update_release target_proj, target_package, target_id, args | |
80 | - logger.info "Release #{target_id} has been updated." | |
82 | + logger.debug "Updating release #{target_release} as #{args.inspect}" | |
83 | + r = api.update_release target_proj, target_package, target_release, args | |
84 | + logger.info "Release #{target_release} has been updated." | |
81 | 85 | puts format_release(r) |
82 | 86 | end |
83 | 87 | |
84 | 88 | def delete |
85 | - target_id = ARGV.shift | |
86 | - r = api.delete_release target_proj, target_package, target_id | |
87 | - logger.info "Release #{target_id} has been deleted." | |
89 | + _set_release_id | |
90 | + r = api.delete_release target_proj, target_package, target_release | |
91 | + logger.info "Release #{target_release} has been deleted." | |
88 | 92 | end |
89 | 93 | |
94 | + def _set_release_id | |
95 | + return if ARGV[0].to_i == 0 | |
96 | + @target_release = ARGV[0].to_i | |
97 | + end | |
90 | 98 | end |
91 | 99 | end; end; end |