-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import java.util.List; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.bladerunnerjs.api.BRJS; | ||
import org.bladerunnerjs.api.logging.Logger; | ||
import org.bladerunnerjs.api.model.exception.command.CommandArgumentsException; | ||
|
@@ -104,13 +105,27 @@ private void getHelpForSpecificCommand(String commandName) throws CommandArgumen | |
logger.println(""); | ||
|
||
logger.println("Help:"); | ||
logger.println( getFormattedHelpMessage(command) ); | ||
} | ||
|
||
private String getFormattedHelpMessage(CommandPlugin command) | ||
{ | ||
String commandHelp = command.getCommandHelp(); | ||
if (commandHelp.length() > 0 && !Character.isWhitespace(commandHelp.charAt(0))) { | ||
commandHelp = " "+commandHelp; | ||
StringBuilder formattedHelp = new StringBuilder(); | ||
for (String line : StringUtils.split(commandHelp, "\n")) { | ||
formattedHelp.append( formatHelpMessageLine(line, 2) + "\n" ); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
logger.println(commandHelp); | ||
return formattedHelp.toString(); | ||
} | ||
|
||
private String formatHelpMessageLine(String line, int expectedWhitespaceCount) { | ||
This comment has been minimized.
Sorry, something went wrong.
dchambers
Contributor
|
||
int lineWhitespace = 0; | ||
while (lineWhitespace < line.length() && line.charAt(lineWhitespace) == ' ') { | ||
lineWhitespace++; | ||
} | ||
return StringUtils.repeat(' ', Math.max(0, expectedWhitespaceCount - lineWhitespace)) + line; | ||
} | ||
|
||
public String getHelpMessageFormatString() | ||
{ | ||
int commandNameSize = getLongestCommandName() + 5; | ||
|
I think this line should just be:
where you modify
JSAPArgsParsingCommandPlugin
to strip the indent that JSAP automatically adds.