|
32 | 32 | import java.net.*; |
33 | 33 | import java.nio.channels.Channels; |
34 | 34 | import java.nio.channels.ReadableByteChannel; |
| 35 | +import java.util.List; |
35 | 36 | import java.util.Scanner; |
36 | 37 | import java.util.concurrent.CountDownLatch; |
37 | 38 | import java.util.concurrent.atomic.AtomicReference; |
@@ -89,9 +90,30 @@ public static Options cliOptionsPublic() { |
89 | 90 |
|
90 | 91 | options.addOption(Option.builder() |
91 | 92 | .longOpt("update") |
| 93 | + .desc("Update Chunky to the latest release") |
| 94 | + .build() |
| 95 | + ); |
| 96 | + |
| 97 | + options.addOption(Option.builder() |
| 98 | + .longOpt("releaseChannel") |
92 | 99 | .argName("release channel") |
93 | 100 | .optionalArg(true) |
94 | | - .desc("Update Chunky to the latest release") |
| 101 | + .desc("Specify the release channel (for use with --update and --chunkyVersion latest)") |
| 102 | + .build() |
| 103 | + ); |
| 104 | + |
| 105 | + options.addOption(Option.builder() |
| 106 | + .longOpt("updateSite") |
| 107 | + .argName("update site") |
| 108 | + .desc("Update site to use for updating") |
| 109 | + .build() |
| 110 | + ); |
| 111 | + |
| 112 | + options.addOption(Option.builder() |
| 113 | + .longOpt("chunkyVersion") |
| 114 | + .argName("chunky version") |
| 115 | + .numberOfArgs(1) |
| 116 | + .desc("Chunky version to launch (latest for the latest installed version of the specified release channel)") |
95 | 117 | .build() |
96 | 118 | ); |
97 | 119 |
|
@@ -197,15 +219,21 @@ public static void main(String[] args) throws FileNotFoundException { |
197 | 219 | settings.forceGuiConsole = true; |
198 | 220 | } |
199 | 221 |
|
200 | | - if (cmd.hasOption("update")) { |
201 | | - ReleaseChannel channel = settings.selectedChannel; |
| 222 | + if (cmd.hasOption("updateSite")) { |
| 223 | + settings.updateSite = cmd.getOptionValue("updateSite"); |
| 224 | + reloadReleaseChannels(settings); |
| 225 | + return; |
| 226 | + } |
202 | 227 |
|
203 | | - String selected = cmd.getOptionValue("update"); |
| 228 | + if (cmd.hasOption("releaseChannel")) { |
| 229 | + String selected = cmd.getOptionValue("releaseChannel"); |
204 | 230 | if (selected != null) { |
205 | | - channel = settings.releaseChannels.getOrDefault(selected, channel); |
| 231 | + settings.selectedChannel = settings.releaseChannels.getOrDefault(selected, settings.selectedChannel); |
206 | 232 | } |
| 233 | + } |
207 | 234 |
|
208 | | - headlessUpdateChunky(settings, channel); |
| 235 | + if (cmd.hasOption("update")) { |
| 236 | + headlessUpdateChunky(settings, settings.selectedChannel); |
209 | 237 | return; |
210 | 238 | } |
211 | 239 |
|
@@ -245,6 +273,14 @@ public static void main(String[] args) throws FileNotFoundException { |
245 | 273 | LauncherSettings.disableLibraryValidation = true; |
246 | 274 | } |
247 | 275 |
|
| 276 | + if (cmd.hasOption("chunkyVersion")) { |
| 277 | + settings.version = cmd.getOptionValue("chunkyVersion"); |
| 278 | + if ("latest".equals(cmd.getOptionValue("chunkyVersion"))) { |
| 279 | + List<VersionInfo> versions = new UpdateChecker(settings, settings.selectedChannel).getVersions(); |
| 280 | + settings.version = versions.stream().findAny().map(version -> version.name).orElse(settings.version); |
| 281 | + } |
| 282 | + } |
| 283 | + |
248 | 284 | headlessOptions = String.join(" ", cmd.getArgList()); |
249 | 285 |
|
250 | 286 | if (forceLauncher) { |
@@ -330,7 +366,7 @@ public static void main(String[] args) throws FileNotFoundException { |
330 | 366 | } |
331 | 367 | e.printStackTrace(System.err); |
332 | 368 | } catch (ParseException e) { |
333 | | - System.out.println(e.getMessage()); |
| 369 | + System.out.println(e.getMessage()); |
334 | 370 | } |
335 | 371 | } |
336 | 372 |
|
|
0 commit comments