| | |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.util.args; |
| | | |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.util.*; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.MessageBuilder; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.util.SetupUtils; |
| | | |
| | | import static org.opends.messages.UtilityMessages.*; |
| | | import static org.opends.server.tools.ToolConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedList; |
| | | import java.util.Map; |
| | | import java.util.Properties; |
| | | import java.util.SortedMap; |
| | | import java.util.TreeMap; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.util.SetupUtils; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a variant of the argument parser that can be used with |
| | | * applications that use subcommands to customize their behavior and that have a |
| | |
| | | */ |
| | | public class SubCommandArgumentParser extends ArgumentParser |
| | | { |
| | | // The argument that will be used to trigger the display of usage information. |
| | | /** |
| | | * The argument that will be used to trigger the display of usage information. |
| | | */ |
| | | private Argument usageArgument; |
| | | |
| | | // The arguments that will be used to trigger the display of usage |
| | | // information for groups of sub-commands. |
| | | /** |
| | | * The arguments that will be used to trigger the display of usage information |
| | | * for groups of sub-commands. |
| | | */ |
| | | private final Map<Argument, Collection<SubCommand>> usageGroupArguments; |
| | | |
| | | // The set of unnamed trailing arguments that were provided for this parser. |
| | | /** |
| | | * The set of unnamed trailing arguments that were provided for this parser. |
| | | */ |
| | | private ArrayList<String> trailingArguments; |
| | | |
| | | // Indicates whether subcommand and long argument names should be treated in a |
| | | // case-sensitive manner. |
| | | /** |
| | | * Indicates whether subcommand and long argument names should be treated in a |
| | | * case-sensitive manner. |
| | | */ |
| | | private final boolean longArgumentsCaseSensitive; |
| | | |
| | | // Indicates whether the usage information has been displayed. |
| | | /** Indicates whether the usage information has been displayed. */ |
| | | private boolean usageOrVersionDisplayed; |
| | | |
| | | // The set of global arguments defined for this parser, referenced by short |
| | | // ID. |
| | | private final HashMap<Character,Argument> globalShortIDMap; |
| | | /** |
| | | * The set of global arguments defined for this parser, referenced by short |
| | | * ID. |
| | | */ |
| | | private final Map<Character, Argument> globalShortIDMap; |
| | | |
| | | // The set of global arguments defined for this parser, referenced by |
| | | // argument name. |
| | | private final HashMap<String,Argument> globalArgumentMap; |
| | | /** |
| | | * The set of global arguments defined for this parser, referenced by argument |
| | | * name. |
| | | */ |
| | | private final Map<String, Argument> globalArgumentMap; |
| | | |
| | | // The set of global arguments defined for this parser, referenced by long |
| | | // ID. |
| | | private final HashMap<String,Argument> globalLongIDMap; |
| | | /** |
| | | * The set of global arguments defined for this parser, referenced by long ID. |
| | | */ |
| | | private final Map<String, Argument> globalLongIDMap; |
| | | |
| | | // The set of subcommands defined for this parser, referenced by subcommand |
| | | // name. |
| | | /** |
| | | * The set of subcommands defined for this parser, referenced by subcommand |
| | | * name. |
| | | */ |
| | | private final SortedMap<String,SubCommand> subCommands; |
| | | |
| | | // The total set of global arguments defined for this parser. |
| | | private final LinkedList<Argument> globalArgumentList; |
| | | /** The total set of global arguments defined for this parser. */ |
| | | private final List<Argument> globalArgumentList; |
| | | |
| | | // The output stream to which usage information should be printed. |
| | | /** The output stream to which usage information should be printed. */ |
| | | private OutputStream usageOutputStream; |
| | | |
| | | // The fully-qualified name of the Java class that should be invoked to launch |
| | | // the program with which this argument parser is associated. |
| | | /** |
| | | * The fully-qualified name of the Java class that should be invoked to launch |
| | | * the program with which this argument parser is associated. |
| | | */ |
| | | private final String mainClassName; |
| | | |
| | | // A human-readable description for the tool, which will be included when |
| | | // displaying usage information. |
| | | /** |
| | | * A human-readable description for the tool, which will be included when |
| | | * displaying usage information. |
| | | */ |
| | | private final Message toolDescription; |
| | | |
| | | // The raw set of command-line arguments that were provided. |
| | | /** The raw set of command-line arguments that were provided. */ |
| | | private String[] rawArguments; |
| | | |
| | | // The subcommand requested by the user as part of the command-line arguments. |
| | | /** |
| | | * The subcommand requested by the user as part of the command-line arguments. |
| | | */ |
| | | private SubCommand subCommand; |
| | | |
| | | //Indicates whether the version argument was provided. |
| | | /**Indicates whether the version argument was provided. */ |
| | | private boolean versionPresent; |
| | | |
| | | private final static String INDENT = " "; |
| | | private final static int MAX_LENGTH = SetupUtils.isWindows() ? 79 : 80; |
| | | private static final String INDENT = " "; |
| | | private static final int MAX_LENGTH = SetupUtils.isWindows() ? 79 : 80; |
| | | |
| | | |
| | | /** |
| | |
| | | * @return The list of all global arguments that have been defined for this |
| | | * argument parser. |
| | | */ |
| | | public LinkedList<Argument> getGlobalArgumentList() |
| | | public List<Argument> getGlobalArgumentList() |
| | | { |
| | | return globalArgumentList; |
| | | } |
| | |
| | | * @return The set of global arguments mapped by the short identifier that |
| | | * may be used to reference them. |
| | | */ |
| | | public HashMap<Character,Argument> getGlobalArgumentsByShortID() |
| | | public Map<Character, Argument> getGlobalArgumentsByShortID() |
| | | { |
| | | return globalShortIDMap; |
| | | } |
| | |
| | | * @return The set of global arguments mapped by the long identifier that may |
| | | * be used to reference them. |
| | | */ |
| | | public HashMap<String,Argument> getGlobalArgumentsByLongID() |
| | | public Map<String, Argument> getGlobalArgumentsByLongID() |
| | | { |
| | | return globalLongIDMap; |
| | | } |
| | |
| | | throw new ArgumentException(ERR_ARG_SUBCOMMAND_INVALID.get()); |
| | | } |
| | | |
| | | if ((subCommand.getMaxTrailingArguments() > 0) && |
| | | (trailingArguments.size() > subCommand.getMaxTrailingArguments())) |
| | | if (subCommand.getMaxTrailingArguments() > 0 |
| | | && trailingArguments.size() > subCommand.getMaxTrailingArguments()) |
| | | { |
| | | Message message = ERR_ARGPARSER_TOO_MANY_TRAILING_ARGS.get( |
| | | subCommand.getMaxTrailingArguments()); |
| | |
| | | { |
| | | // "--help" will always be interpreted as requesting usage |
| | | // information. |
| | | try |
| | | { |
| | | getUsage(usageOutputStream); |
| | | } catch (Exception e) {} |
| | | |
| | | getUsage(usageOutputStream); |
| | | return; |
| | | } |
| | | else |
| | |
| | | { |
| | | // "--version" will always be interpreted as requesting usage |
| | | // information. |
| | | try |
| | | { |
| | | versionPresent = true; |
| | | DirectoryServer.printVersion(usageOutputStream); |
| | | usageOrVersionDisplayed = true ; |
| | | } catch (Exception e) {} |
| | | |
| | | versionPresent = true; |
| | | usageOrVersionDisplayed = true ; |
| | | printVersion(); |
| | | return; |
| | | } |
| | | else |
| | |
| | | { |
| | | // "--help" will always be interpreted as requesting usage |
| | | // information. |
| | | try |
| | | { |
| | | getUsage(usageOutputStream); |
| | | } catch (Exception e) {} |
| | | |
| | | getUsage(usageOutputStream); |
| | | return; |
| | | } |
| | | else |
| | |
| | | { |
| | | // "--version" will always be interpreted as requesting usage |
| | | // information. |
| | | try |
| | | { |
| | | versionPresent = true; |
| | | DirectoryServer.printVersion(usageOutputStream); |
| | | usageOrVersionDisplayed = true ; |
| | | } catch (Exception e) {} |
| | | |
| | | versionPresent = true; |
| | | usageOrVersionDisplayed = true ; |
| | | printVersion(); |
| | | return; |
| | | } |
| | | else |
| | |
| | | // usage information. |
| | | if (usageGroupArguments.containsKey(a)) |
| | | { |
| | | try |
| | | { |
| | | getUsage(a, usageOutputStream); |
| | | } catch (Exception e) {} |
| | | |
| | | getUsage(a, usageOutputStream); |
| | | return; |
| | | } |
| | | |
| | |
| | | |
| | | // If the argument already has a value, then make sure it is |
| | | // acceptable to have more than one. |
| | | if (a.hasValue() && (! a.isMultiValued())) |
| | | if (a.hasValue() && !a.isMultiValued()) |
| | | { |
| | | Message message = |
| | | ERR_SUBCMDPARSER_NOT_MULTIVALUED_FOR_LONG_ID.get(origArgName); |
| | |
| | | if (argCharacter == '?') |
| | | { |
| | | // "-?" will always be interpreted as requesting usage. |
| | | try |
| | | getUsage(usageOutputStream); |
| | | if (usageArgument != null) |
| | | { |
| | | getUsage(usageOutputStream); |
| | | if (usageArgument != null) |
| | | { |
| | | usageArgument.setPresent(true); |
| | | } |
| | | } catch (Exception e) {} |
| | | |
| | | usageArgument.setPresent(true); |
| | | } |
| | | return; |
| | | } |
| | | else |
| | |
| | | { |
| | | // "-V" will always be interpreted as requesting |
| | | // version information except if it's already defined. |
| | | boolean dashVAccepted = true; |
| | | if (globalShortIDMap.containsKey(OPTION_SHORT_PRODUCT_VERSION)) |
| | | { |
| | | dashVAccepted = false; |
| | | } |
| | | else |
| | | { |
| | | for (SubCommand subCmd : subCommands.values()) |
| | | { |
| | | if (subCmd.getArgument(OPTION_SHORT_PRODUCT_VERSION) != null) |
| | | { |
| | | dashVAccepted = false; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (dashVAccepted) |
| | | if (dashVAccepted()) |
| | | { |
| | | usageOrVersionDisplayed = true; |
| | | versionPresent = true; |
| | | try |
| | | { |
| | | DirectoryServer.printVersion(usageOutputStream); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | } |
| | | printVersion(); |
| | | return; |
| | | } |
| | | else |
| | |
| | | if (argCharacter == '?') |
| | | { |
| | | // "-?" will always be interpreted as requesting usage. |
| | | try |
| | | { |
| | | getUsage(usageOutputStream); |
| | | } catch (Exception e) {} |
| | | |
| | | getUsage(usageOutputStream); |
| | | return; |
| | | } |
| | | else |
| | | if (argCharacter == OPTION_SHORT_PRODUCT_VERSION) |
| | | { |
| | | // "-V" will always be interpreted as requesting |
| | | // version information except if it's already defined. |
| | | boolean dashVAccepted = true; |
| | | if (globalShortIDMap.containsKey(OPTION_SHORT_PRODUCT_VERSION)) |
| | | { |
| | | dashVAccepted = false; |
| | | } |
| | | else |
| | | { |
| | | for (SubCommand subCmd : subCommands.values()) |
| | | { |
| | | if (subCmd.getArgument(OPTION_SHORT_PRODUCT_VERSION)!=null) |
| | | { |
| | | dashVAccepted = false; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (dashVAccepted) |
| | | if (dashVAccepted()) |
| | | { |
| | | usageOrVersionDisplayed = true; |
| | | versionPresent = true; |
| | | try |
| | | { |
| | | DirectoryServer.printVersion(usageOutputStream); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | } |
| | | printVersion(); |
| | | return; |
| | | } |
| | | } |
| | |
| | | // usage information. |
| | | if (usageGroupArguments.containsKey(a)) |
| | | { |
| | | try |
| | | { |
| | | getUsage(a, usageOutputStream); |
| | | } catch (Exception e) {} |
| | | |
| | | getUsage(a, usageOutputStream); |
| | | return; |
| | | } |
| | | |
| | |
| | | |
| | | // If the argument already has a value, then make sure it is |
| | | // acceptable to have more than one. |
| | | if (a.hasValue() && (! a.isMultiValued())) |
| | | if (a.hasValue() && !a.isMultiValued()) |
| | | { |
| | | Message message = ERR_SUBCMDPARSER_NOT_MULTIVALUED_FOR_SHORT_ID.get( |
| | | String.valueOf(argCharacter)); |
| | |
| | | // print usage information. |
| | | if (usageGroupArguments.containsKey(b)) |
| | | { |
| | | try |
| | | { |
| | | getUsage(b, usageOutputStream); |
| | | } catch (Exception e) {} |
| | | |
| | | getUsage(b, usageOutputStream); |
| | | return; |
| | | } |
| | | } |
| | |
| | | if (subCommand != null) |
| | | { |
| | | int minTrailingArguments = subCommand.getMinTrailingArguments(); |
| | | if (subCommand.allowsTrailingArguments() && (minTrailingArguments > 0)) |
| | | if (subCommand.allowsTrailingArguments() && minTrailingArguments > 0 |
| | | && trailingArguments.size() < minTrailingArguments) |
| | | { |
| | | if (trailingArguments.size() < minTrailingArguments) |
| | | { |
| | | Message message = ERR_ARGPARSER_TOO_FEW_TRAILING_ARGUMENTS.get( |
| | | minTrailingArguments); |
| | | throw new ArgumentException(message); |
| | | } |
| | | Message message = |
| | | ERR_ARGPARSER_TOO_FEW_TRAILING_ARGUMENTS.get(minTrailingArguments); |
| | | throw new ArgumentException(message); |
| | | } |
| | | } |
| | | |
| | |
| | | argumentProperties = checkExternalProperties(); |
| | | } |
| | | |
| | | // Iterate through all the global arguments and make sure that they have |
| | | // values or a suitable default is available. |
| | | for (Argument a : globalArgumentList) |
| | | // Iterate through all the global arguments |
| | | normalizeArguments(argumentProperties, globalArgumentList); |
| | | |
| | | |
| | | // Iterate through all the subcommand-specific arguments |
| | | if (subCommand != null) |
| | | { |
| | | if (! a.isPresent()) |
| | | normalizeArguments(argumentProperties, subCommand.getArguments()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Iterate through all the arguments and make sure that they have values or a |
| | | * suitable default is available. |
| | | */ |
| | | private void normalizeArguments(Properties argumentProperties, |
| | | List<Argument> arguments) throws ArgumentException |
| | | { |
| | | for (Argument a : arguments) |
| | | { |
| | | if (!a.isPresent() |
| | | && argumentProperties != null |
| | | && a.getPropertyName() != null) |
| | | { |
| | | // See if there is a value in the properties that can be used |
| | | if ((argumentProperties != null) && (a.getPropertyName() != null)) |
| | | String value = |
| | | argumentProperties.getProperty(a.getPropertyName().toLowerCase()); |
| | | MessageBuilder invalidReason = new MessageBuilder(); |
| | | if (value != null) |
| | | { |
| | | String value = argumentProperties.getProperty(a.getPropertyName() |
| | | .toLowerCase()); |
| | | MessageBuilder invalidReason = new MessageBuilder(); |
| | | if (value != null) |
| | | Boolean addValue = true; |
| | | if (!(a instanceof BooleanArgument)) |
| | | { |
| | | Boolean addValue = true; |
| | | if (!( a instanceof BooleanArgument)) |
| | | addValue = a.valueIsAcceptable(value, invalidReason); |
| | | } |
| | | if (addValue) |
| | | { |
| | | a.addValue(value); |
| | | if (a.needsValue()) |
| | | { |
| | | addValue = a.valueIsAcceptable(value, invalidReason); |
| | | a.setPresent(true); |
| | | } |
| | | if (addValue) |
| | | { |
| | | a.addValue(value); |
| | | if (a.needsValue()) |
| | | { |
| | | a.setPresent(true); |
| | | } |
| | | a.setValueSetByProperty(true); |
| | | } |
| | | a.setValueSetByProperty(true); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if ((! a.isPresent()) && a.needsValue()) |
| | | if (!a.isPresent() && a.needsValue()) |
| | | { |
| | | // ISee if the argument defines a default. |
| | | // See if the argument defines a default. |
| | | if (a.getDefaultValue() != null) |
| | | { |
| | | a.addValue(a.getDefaultValue()); |
| | | } |
| | | |
| | | // If there is still no value and the argument is required, then that's |
| | | // a problem. |
| | | if ((! a.hasValue()) && a.isRequired()) |
| | | // If there is still no value and the argument is required, then |
| | | // that's a problem. |
| | | if (!a.hasValue() && a.isRequired()) |
| | | { |
| | | Message message = |
| | | ERR_SUBCMDPARSER_NO_VALUE_FOR_REQUIRED_ARG.get(a.getName()); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // Iterate through all the subcommand-specific arguments and make sure that |
| | | // they have values or a suitable default is available. |
| | | if (subCommand != null) |
| | | { |
| | | for (Argument a : subCommand.getArguments()) |
| | | { |
| | | if (! a.isPresent()) |
| | | { |
| | | // See if there is a value in the properties that can be used |
| | | if ((argumentProperties != null) && (a.getPropertyName() != null)) |
| | | { |
| | | String value = argumentProperties.getProperty(a.getPropertyName() |
| | | .toLowerCase()); |
| | | MessageBuilder invalidReason = new MessageBuilder(); |
| | | if (value != null) |
| | | { |
| | | Boolean addValue = true; |
| | | if (!( a instanceof BooleanArgument)) |
| | | { |
| | | addValue = a.valueIsAcceptable(value, invalidReason); |
| | | } |
| | | if (addValue) |
| | | { |
| | | a.addValue(value); |
| | | if (a.needsValue()) |
| | | { |
| | | a.setPresent(true); |
| | | } |
| | | a.setValueSetByProperty(true); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if ((! a.isPresent()) && a.needsValue()) |
| | | { |
| | | // See if the argument defines a default. |
| | | if (a.getDefaultValue() != null) |
| | | { |
| | | a.addValue(a.getDefaultValue()); |
| | | } |
| | | |
| | | // If there is still no value and the argument is required, then |
| | | // that's a problem. |
| | | if ((! a.hasValue()) && a.isRequired()) |
| | | { |
| | | Message message = |
| | | ERR_SUBCMDPARSER_NO_VALUE_FOR_REQUIRED_ARG.get(a.getName()); |
| | | throw new ArgumentException(message); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void printVersion() |
| | | { |
| | | try |
| | | { |
| | | DirectoryServer.printVersion(usageOutputStream); |
| | | } |
| | | catch (Exception e) {} |
| | | } |
| | | |
| | | private boolean dashVAccepted() |
| | | { |
| | | if (globalShortIDMap.containsKey(OPTION_SHORT_PRODUCT_VERSION)) |
| | | { |
| | | return false; |
| | | } |
| | | for (SubCommand subCmd : subCommands.values()) |
| | | { |
| | | if (subCmd.getArgument(OPTION_SHORT_PRODUCT_VERSION) != null) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * Appends usage information for the specified subcommand to the provided |
| | |
| | | { |
| | | usageOrVersionDisplayed = true; |
| | | String scriptName = System.getProperty(PROPERTY_SCRIPT_NAME); |
| | | if ((scriptName == null) || (scriptName.length() == 0)) |
| | | if (scriptName == null || scriptName.length() == 0) |
| | | { |
| | | scriptName = "java " + mainClassName; |
| | | } |
| | |
| | | if (lineLength > MAX_LENGTH) |
| | | { |
| | | buffer.append(EOL); |
| | | buffer.append(newBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | buffer.append(newBuffer.toString()); |
| | | } |
| | | buffer.append(newBuffer.toString()); |
| | | } |
| | | |
| | | buffer.append(EOL); |
| | |
| | | buffer.append(EOL); |
| | | } |
| | | } |
| | | if (a.needsValue() && (a.getDefaultValue() != null) && |
| | | (a.getDefaultValue().length() > 0)) |
| | | if (a.needsValue() |
| | | && a.getDefaultValue() != null |
| | | && a.getDefaultValue().length() > 0) |
| | | { |
| | | buffer.append(INDENT); |
| | | buffer.append(INFO_ARGPARSER_USAGE_DEFAULT_VALUE.get( |
| | |
| | | { |
| | | usageOrVersionDisplayed = true; |
| | | String scriptName = System.getProperty(PROPERTY_SCRIPT_NAME); |
| | | if ((scriptName == null) || (scriptName.length() == 0)) |
| | | if (scriptName == null || scriptName.length() == 0) |
| | | { |
| | | scriptName = "java " + mainClassName; |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | // Get usage for a specific usage argument. |
| | | private void getUsage(Argument a, OutputStream outputStream) |
| | | throws IOException { |
| | | /** Get usage for a specific usage argument. */ |
| | | private void getUsage(Argument a, OutputStream outputStream) { |
| | | MessageBuilder buffer = new MessageBuilder(); |
| | | |
| | | if (a.equals(usageArgument) && subCommand != null) { |
| | |
| | | getFullUsage(usageGroupArguments.get(a), false, buffer); |
| | | } |
| | | |
| | | outputStream.write(buffer.toString().getBytes()); |
| | | try |
| | | { |
| | | outputStream.write(buffer.toString().getBytes()); |
| | | } catch (Exception e) {} |
| | | } |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void getUsage(OutputStream outputStream) |
| | | { |
| | | try |
| | | { |
| | | outputStream.write(getUsage().getBytes()); |
| | | } |
| | | catch (IOException e) {} |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | * Appends complete usage information for the specified set of sub-commands. |
| | | */ |
| | | @Override |
| | | public void getUsage(OutputStream outputStream) |
| | | throws IOException { |
| | | outputStream.write(getUsage().getBytes()); |
| | | } |
| | | |
| | | |
| | | |
| | | // Appends complete usage information for the specified set of |
| | | // sub-commands. |
| | | private void getFullUsage(Collection<SubCommand> c, |
| | | boolean showGlobalOptions, MessageBuilder buffer) { |
| | | usageOrVersionDisplayed = true; |
| | | if ((toolDescription != null) && (toolDescription.length() > 0)) |
| | | if (toolDescription != null && toolDescription.length() > 0) |
| | | { |
| | | buffer.append(wrapText(toolDescription, MAX_LENGTH - 1)); |
| | | buffer.append(EOL); |
| | |
| | | } |
| | | |
| | | String scriptName = System.getProperty(PROPERTY_SCRIPT_NAME); |
| | | if ((scriptName == null) || (scriptName.length() == 0)) |
| | | if (scriptName == null || scriptName.length() == 0) |
| | | { |
| | | scriptName = "java " + mainClassName; |
| | | } |
| | |
| | | |
| | | if (subCommands.isEmpty()) |
| | | { |
| | | buffer.append(" "+INFO_SUBCMDPARSER_OPTIONS.get()); |
| | | buffer.append(" ").append(INFO_SUBCMDPARSER_OPTIONS.get()); |
| | | } |
| | | else |
| | | { |
| | | buffer.append(" "+INFO_SUBCMDPARSER_SUBCMD_AND_OPTIONS.get()); |
| | | buffer.append(" ").append(INFO_SUBCMDPARSER_SUBCMD_AND_OPTIONS.get()); |
| | | } |
| | | |
| | | if (!subCommands.isEmpty()) |
| | |
| | | continue; |
| | | } |
| | | |
| | | if (usageGroupArguments.containsKey(a)) { |
| | | if (!a.equals(usageArgument)) { |
| | | printArgumentUsage(a, buffer); |
| | | } |
| | | if (usageGroupArguments.containsKey(a) |
| | | && !a.equals(usageArgument)) { |
| | | printArgumentUsage(a, buffer); |
| | | } |
| | | } |
| | | } else { |
| | |
| | | if (subCommands.isEmpty()) |
| | | { |
| | | buffer.append(INFO_SUBCMDPARSER_WHERE_OPTIONS_INCLUDE.get()); |
| | | buffer.append(EOL); |
| | | } |
| | | else |
| | | { |
| | | buffer.append(INFO_SUBCMDPARSER_GLOBAL_HEADING.get()); |
| | | buffer.append(EOL); |
| | | } |
| | | buffer.append(EOL); |
| | | buffer.append(EOL); |
| | | |
| | | boolean printGroupHeaders = printUsageGroupHeaders(); |
| | | |
| | |
| | | buffer.append(EOL); |
| | | indentAndWrap(Message.raw(INDENT), a.getDescription(), buffer); |
| | | |
| | | if (a.needsValue() && (a.getDefaultValue() != null) && |
| | | (a.getDefaultValue().length() > 0)) |
| | | if (a.needsValue() |
| | | && a.getDefaultValue() != null |
| | | && a.getDefaultValue().length() > 0) |
| | | { |
| | | indentAndWrap(Message.raw(INDENT), |
| | | INFO_ARGPARSER_USAGE_DEFAULT_VALUE.get(a.getDefaultValue()), |
| | |
| | | |
| | | return "<refsect2 xml:id=\"dsconfig-" + sc.getName() + "\">" + EOL + |
| | | " <title>dsconfig " + sc.getName() + "</title>" + EOL + |
| | | " <para>" + sc.getDescription().toString() + "</para>" + EOL + |
| | | " <para>" + sc.getDescription() + "</para>" + EOL + |
| | | options + |
| | | "</refsect2>" + EOL; |
| | | } |