From d1711f36fb683c367ef02c10c8eb98fc71308ab4 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 21 Jul 2008 01:32:00 -0400 Subject: [PATCH] Include commonly used commands in main help output If the main loop did not get a subcommand during parsing of the command line then we should offer up a list of commonly used commands and their one-line usage summary, to help the user make a decision about which command they should try to execute. Signed-off-by: Shawn O. Pearce --- .../src/org/spearce/jgit/pgm/Main.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Main.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Main.java index c069989f..c8bade82 100644 --- a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Main.java +++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Main.java @@ -121,6 +121,24 @@ public class Main { System.err.println(); clp.printUsage(System.err); System.err.println(); + } else if (subcommand == null) { + System.err.println(); + System.err.println("The most commonly used commands are:"); + final CommandRef[] common = CommandCatalog.common(); + int width = 0; + for (final CommandRef c : common) + width = Math.max(width, c.getName().length()); + width += 2; + + for (final CommandRef c : common) { + System.err.print(' '); + System.err.print(c.getName()); + for (int i = c.getName().length(); i < width; i++) + System.err.print(' '); + System.err.print(c.getUsage()); + System.err.println(); + } + System.err.println(); } System.exit(1); } -- 2.11.4.GIT