Skip to content

Commit 1cf1487

Browse files
committed
[MNG-6915] Format help according to the terminal width
1 parent 151e349 commit 1cf1487

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.apache.commons.cli.Option;
3030
import org.apache.commons.cli.Options;
3131
import org.apache.commons.cli.ParseException;
32+
import org.apache.maven.shared.utils.logging.MessageUtils;
3233

3334
/**
3435
* @author Jason van Zyl
@@ -170,7 +171,13 @@ public void displayHelp( PrintStream stdout )
170171

171172
HelpFormatter formatter = new HelpFormatter();
172173

173-
formatter.printHelp( pw, HelpFormatter.DEFAULT_WIDTH, "mvn [options] [<goal(s)>] [<phase(s)>]",
174+
int width = MessageUtils.getTerminalWidth();
175+
if ( width <= 0 )
176+
{
177+
width = HelpFormatter.DEFAULT_WIDTH;
178+
}
179+
180+
formatter.printHelp( pw, width, "mvn [options] [<goal(s)>] [<phase(s)>]",
174181
System.lineSeparator() + "Options:", options,
175182
HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD,
176183
System.lineSeparator(), false );

0 commit comments

Comments
 (0)