base/common/src/main/com/thesett/common/util/CommandLineParser.java
public String getUsage()
    {
        String result = "Options:\n";

        int optionWidth = 0;
        int argumentWidth = 0;

        // Calculate the column widths required for aligned layout.
        for (CommandLineOption optionInfo : optionMap.values())
        {
            int oWidth = optionInfo.option.length();
            int aWidth = (optionInfo.argument != null) ? (optionInfo.argument.length()) : 0;

            optionWidth = (oWidth > optionWidth) ? oWidth : optionWidth;
            argumentWidth = (aWidth > argumentWidth) ? aWidth : argumentWidth;
        }

        // Print usage on each of the command line options.
        for (CommandLineOption optionInfo : optionMap.values())
        {
            String argString = ((optionInfo.argument != null) ? (optionInfo.argument) : "");
            String optionString = optionInfo.option;

            argString = rightPad(argString, " ", argumentWidth);
            optionString = rightPad(optionString, " ", optionWidth);

            result += "-" + optionString + " " + argString + " " + optionInfo.comment + "\n";
        }

        return result;
    }
public String getUsage()
    {
        String result = "Options:\n";

        int optionWidth = 0;
        int argumentWidth = 0;

        // Calculate the column widths required for aligned layout.
        for (CommandLineOption optionInfo : optionMap.values())
        {
            int oWidth = optionInfo.option.length();
            int aWidth = (optionInfo.argument != null) ? (optionInfo.argument.length()) : 0;

            optionWidth = (oWidth > optionWidth) ? oWidth : optionWidth;
            argumentWidth = (aWidth > argumentWidth) ? aWidth : argumentWidth;
        }

        // Print usage on each of the command line options.
        for (CommandLineOption optionInfo : optionMap.values())
        {
            String argString = ((optionInfo.argument != null) ? (optionInfo.argument) : "");
            String optionString = optionInfo.option;

            argString = rightPad(argString, " ", argumentWidth);
            optionString = rightPad(optionString, " ", optionWidth);

            result += "-" + optionString + " " + argString + " " + optionInfo.comment + "\n";
        }

        return result;
    }
Generates a usage string consisting of the name of each option and each options argument description and comment.

@return A usage string for all the options.