Class: Zypper::Upgraderepo::OptParseMain
- Inherits:
-
Object
- Object
- Zypper::Upgraderepo::OptParseMain
- Defined in:
- lib/zypper/upgraderepo/cli.rb
Overview
Parsing the input data.
Class Method Summary collapse
Class Method Details
.parse(_args) ⇒ Object
20 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/zypper/upgraderepo/cli.rb', line 20 def self.parse(_args) = CliOptions.new .operation = :check_current .backup_path = Dir.home .only_enabled = false .alias = true .name = true .hint = true .overrides = {} .version = nil .sorting_by = :alias .view = :table .only_repo = nil .timeout = 10.0 .exit_on_fail = false .overrides_filename = nil .only_invalid = false .only_protocols = nil .allow_unstable = false opt_parser = OptionParser.new do |opt| opt. = if ENV["ZYPPER_UPGRADEREPO"] "Usage: zypper upgraderepo [OPTIONS] [OPERATION]" else "Usage: upgraderepo [OPTIONS] [OPERATION]" end opt.separator "" opt.separator "Operations:" opt.on("-b", "--backup <PATH>", "Create a Tar backup of all the repositories under PATH") do |o| .operation = :backup .only_enabled = false .backup_path = o end opt.on("-c", "--check-current", "Check the repositories for the current version (Default)") do |_o| .operation = :check_current end opt.on("-n", "--check-next", "Check the repositories for the next version") do |_o| .operation = :check_next end opt.on("-C", "--check-for <VERSION>", "Check for a custom VERSION") do |v| .version = v .operation = :check_for end opt.on("-l", "--check-last", "Check the repositories for the last version") do |_o| .operation = :check_last end opt.on("-R", "--reset", "Reset the repositories to the current OS version.") do |_v| .operation = :reset end opt.on("-t", "--update", "Update the repositories to the current OS version") do |_v| .operation = :update end opt.on("-u", "--upgrade", "Upgrade to the next version available") do |_o| .operation = :upgrade_to_next end opt.on("-U", "--upgrade-to <VERSION>", "Upgrade to a specific VERSION") do |v| .version = v .operation = :upgrade_to end opt.on("-L", "--upgrade-to-last", "Upgrade to the last version available") do |_o| .operation = :upgrade_to_last end opt.on("-s", "--status", "Prints the version status of the current and available releases") do |_o| .operation = :status end opt.on("-d", "--duplicates", "Detect the duplicates comparing the URL addresses") do |_o| .operation = :duplicates end opt.on("-z", "--unused", "Prints the unused repositories with zero packages installed") do |_o| .operation = :unused end opt.separator "" opt.separator "Options:" opt.on("--allow-unstable", "Consider the unstable version as a valid release version") do |_o| .allow_unstable = true end opt.on("--no-name", "Don't upgrade the name") do |_o| .name = false end opt.on("--no-alias", "Don't upgrade the alias") do |_o| .alias = false end opt.on("--no-hint", "Don't find a working URL when the current is not valid") do |_o| .hint = false end opt.on("--override-url <NUMBER>,<URL>", Array, "Overwrite the repository NUMBER with URL") do |r| .overrides[r[0].to_i] = r[1] end opt.on("--load-overrides <FILENAME>", "Load the repositories' overrides from FILENAME") do |f| .overrides_filename = f end opt.on("--exit-on-fail", "Exit with error when a repository upgrade check fails") do |_o| .exit_on_fail = true end opt.on("--timeout <SECONDS>", "Adjust the waiting SECONDS used to catch an HTTP Timeout Error (Default: #{.timeout})") do |o| .timeout = o.to_f end opt.separator "" opt.separator "Filter options:" opt.on("--only-enabled", "Include only the enabled repositories") do |_o| .only_enabled = true end opt.on("--only-repo <NUMBER|NAME|@ALIAS|#URL|&ANY>[,NUMBER2|NAME2|@ALIAS2|#URL2|&ANY2,...]", "Include only the repositories specified by a NUMBER or a string matching the NAME, " \ "@ALIAS, #URL, or &ANY of them") do |o| .only_repo = o.split(",") end opt.on("--only-invalid", "Show only invalid repositories") do |_o| .only_invalid = true end opt.on("--only-protocols <PROTOCOL>[,<PROTOCOL2>,...]", Array, "Show only from protocols (supported: #{Request.protocols.join(",")})") do |o| .only_protocols = o end opt.separator "" opt.separator "View options:" opt.on("--sort-by-alias", "Sort the repositories by alias (Default)") do |_o| .sorting_by = :alias end opt.on("--sort-by-name", "Sort the repositories by name") do |_o| .sorting_by = :name end opt.on("--sort-by-priority", "Sort the repositories by priority") do |_o| .sorting_by = :priority end opt.on("--ini", "Output the result in the INI format") do |_o| .view = :ini end opt.on("--quiet", "Quiet mode, show only error messages") do |_o| .view = :quiet end opt.on("--report", "View the data as a report") do |_o| .view = :report end opt.on("--solved", "Output as INI and the URLs' suggestions applied") do |_o| .view = :solved end unless ENV["ZYPPER_UPGRADEREPO"] opt.separator "" opt.separator "Other:" opt.on_tail("-h", "--help", "Show this message") do |_o| puts opt exit end opt.on_tail("-v", "--version", "Show the version") do |_o| puts VERSION exit end end end if ARGV.empty? puts opt_parser exit else opt_parser.parse!(ARGV) end end |