From 0f9c705980652d6d85c9b97346547f87c69a42df Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 2 Jan 2014 11:42:59 -0800 Subject: [PATCH] Rework OptionHandler '-cp' argument support Change OptionHandler to support '-cp' instead of '--cp'. This update to the original fix (045088e8b) renders `help` output correctly and should prevent potential issues if a `-p` command is added in the future. Fixes gh-178 --- .../springframework/boot/cli/command/OptionHandler.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/OptionHandler.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/OptionHandler.java index 390ca0176c..c6a37ca7dd 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/OptionHandler.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/OptionHandler.java @@ -84,6 +84,12 @@ public class OptionHandler { } public final void run(String... args) throws Exception { + String[] argsToUse = args.clone(); + for (int i = 0; i < argsToUse.length; i++) { + if ("-cp".equals(argsToUse[i])) { + argsToUse[i] = "--cp"; + } + } OptionSet options = getParser().parse(args); run(options); } @@ -106,7 +112,7 @@ public class OptionHandler { catch (IOException ex) { return "Help not available"; } - this.help = out.toString(); + this.help = out.toString().replace(" --cp ", " -cp "); } return this.help; } @@ -169,6 +175,7 @@ public class OptionHandler { this.options.add((option.length() == 1 ? "-" : "--") + option); } if (this.options.contains("--cp")) { + this.options.remove("--cp"); this.options.add("-cp"); } this.description = descriptor.description();