opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliArgumentParser.java
@@ -439,11 +439,18 @@ INFO_DESCRIPTION_NO_PROMPT.get()); defaultArgs.add(index++, noPromptArg); for (int i=0; i<index; i++) { Argument arg = defaultArgs.get(i); arg.setPropertyName(arg.getLongIdentifier()); } quietArg = new BooleanArgument( OPTION_LONG_QUIET, OPTION_SHORT_QUIET, OPTION_LONG_QUIET, INFO_REPLICATION_DESCRIPTION_QUIET.get()); quietArg.setPropertyName(OPTION_LONG_QUIET); defaultArgs.add(quietArg); StringArgument propertiesFileArgument = new StringArgument( @@ -575,6 +582,7 @@ }; for (int i=0; i<argsToAdd.length; i++) { argsToAdd[i].setPropertyName(argsToAdd[i].getLongIdentifier()); enableReplicationSubCmd.addArgument(argsToAdd[i]); } } @@ -594,7 +602,7 @@ secureArgsList.hostNameArg.setDefaultValue(getDefaultHostValue()); secureArgsList.bindDnArg = new StringArgument("bindDN", OPTION_SHORT_BINDDN, OPTION_LONG_BINDDN, false, false, true, OPTION_VALUE_BINDDN, "cn=Directory Manager", null, "cn=Directory Manager", OPTION_LONG_BINDDN, INFO_DESCRIPTION_DISABLE_REPLICATION_BINDDN.get()); Argument[] argsToAdd = { secureArgsList.hostNameArg, secureArgsList.portArg, secureArgsList.useSSLArg, @@ -658,6 +666,7 @@ }; for (int i=0; i<argsToAdd.length; i++) { argsToAdd[i].setPropertyName(argsToAdd[i].getLongIdentifier()); initializeReplicationSubCmd.addArgument(argsToAdd[i]); } } @@ -701,6 +710,7 @@ 's', "script-friendly", INFO_DESCRIPTION_SCRIPT_FRIENDLY.get()); scriptFriendlyArg.setPropertyName(scriptFriendlyArg.getLongIdentifier()); secureArgsList.hostNameArg.setDefaultValue(getDefaultHostValue()); Argument[] argsToAdd = { secureArgsList.hostNameArg, secureArgsList.portArg, secureArgsList.useSSLArg, opends/src/guitools/org/opends/guitools/uninstaller/UninstallLauncher.java
@@ -28,6 +28,8 @@ package org.opends.guitools.uninstaller; import static org.opends.messages.AdminToolMessages.*; import static org.opends.messages.ToolMessages.ERR_ERROR_PARSING_ARGS; import org.opends.messages.Message; import org.opends.messages.ToolMessages; @@ -37,6 +39,7 @@ import org.opends.quicksetup.Launcher; import org.opends.quicksetup.Installation; import org.opends.quicksetup.QuickSetupLog; import org.opends.quicksetup.ReturnCode; import org.opends.quicksetup.util.Utils; import org.opends.server.util.ServerConstants; import org.opends.server.util.args.ArgumentException; @@ -101,6 +104,38 @@ } /** * {@inheritDoc} */ public void launch() { // Validate user provided data try { argParser.parseArguments(args); if (argParser.isVersionArgumentPresent()) { System.exit(ReturnCode.PRINT_VERSION.getReturnCode()); } else if (argParser.isUsageArgumentPresent()) { System.exit(ReturnCode.SUCCESSFUL.getReturnCode()); } else { super.launch(); } } catch (ArgumentException ae) { Message message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); System.err.println(message); System.err.println(); System.err.println(argParser.getUsage()); System.exit(ReturnCode.USER_DATA_ERROR.getReturnCode()); } } /** * Initialize the contents of the argument parser. */ protected void initializeParser() @@ -165,4 +200,58 @@ return INFO_FRAME_UNINSTALL_TITLE.get(); } /** * Indicates whether or not the launcher should print a usage * statement based on the content of the arguments passed into * the constructor. * @return boolean where true indicates usage should be printed */ protected boolean shouldPrintUsage() { return argParser.isUsageArgumentPresent() && !argParser.usageOrVersionDisplayed(); } /** * Indicates whether or not the launcher should print a usage * statement based on the content of the arguments passed into * the constructor. * @return boolean where true indicates usage should be printed */ protected boolean isQuiet() { return argParser.isQuiet(); } /** * Indicates whether or not the launcher should print a usage * statement based on the content of the arguments passed into * the constructor. * @return boolean where true indicates usage should be printed */ protected boolean isNoPrompt() { return !argParser.isInteractive(); } /** * Indicates whether or not the launcher should print a version * statement based on the content of the arguments passed into * the constructor. * @return boolean where true indicates version should be printed */ protected boolean shouldPrintVersion() { return argParser.isVersionArgumentPresent() && !argParser.usageOrVersionDisplayed(); } /** * Indicates whether the launcher will launch a command line versus * a graphical application based on the contents of the arguments * passed into the constructor. * * @return boolean where true indicates that a CLI application * should be launched */ protected boolean isCli() { return argParser.isCli(); } } opends/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java
@@ -175,6 +175,11 @@ INFO_UNINSTALLDS_DESCRIPTION_QUIET.get()); args.add(quietArg); for (Argument arg : args) { arg.setPropertyName(arg.getLongIdentifier()); } ArrayList<Argument> defaultArgs = new ArrayList<Argument>(createGlobalArguments(outStream)); int index = defaultArgs.indexOf(secureArgsList.bindDnArg); @@ -191,14 +196,13 @@ defaultArgs.remove(secureArgsList.hostNameArg); defaultArgs.remove(secureArgsList.portArg); defaultArgs.remove(verboseArg); defaultArgs.remove(noPropertiesFileArg); defaultArgs.remove(propertiesFileArg); UserData uData = new UserData(); referencedHostNameArg = new StringArgument("referencedHostName", ToolConstants.OPTION_SHORT_HOST, OPTION_LONG_REFERENCED_HOST_NAME, false, false, true, ToolConstants.OPTION_VALUE_HOST, uData.getHostName(), null, INFO_DESCRIPTION_REFERENCED_HOST.get()); uData.getHostName(), OPTION_LONG_REFERENCED_HOST_NAME, INFO_DESCRIPTION_REFERENCED_HOST.get()); defaultArgs.add(referencedHostNameArg); args.addAll(defaultArgs); @@ -407,6 +411,16 @@ } /** * Returns whether the command was launched in CLI mode or not. * @return <CODE>true</CODE> if the command was launched to use CLI mode and * <CODE>false</CODE> otherwise. */ public boolean isCli() { return cliArg.isPresent(); } /** * Returns the SecureConnectionCliArgs object containing the arguments * of this parser. * @return the SecureConnectionCliArgs object containing the arguments opends/src/messages/messages/admin_tool.properties
@@ -363,8 +363,8 @@ install. If not specified the graphical interface will be launched. The \ rest of the options (excluding help and version) will only be taken into \ account if this option is specified INFO_UNINSTALLDS_DESCRIPTION_QUIET=Perform a quiet uninstall (no \ progress information is written to the standard output) INFO_UNINSTALLDS_DESCRIPTION_QUIET=Run uninstall in quiet mode. Quiet mode \ will not output progress information to standard output INFO_UNINSTALLDS_DESCRIPTION_REMOVE_ALL=Remove all components of \ OpenDS (this option is not compatible with the rest of remove options) INFO_UNINSTALLDS_DESCRIPTION_REMOVE_SERVER_LIBRARIES=Remove Server Libraries \ opends/src/messages/messages/tools.properties
@@ -854,7 +854,8 @@ started properly INFO_INSTALLDS_DESCRIPTION_PROGNAME_486=The setup command used to invoke this \ program INFO_INSTALLDS_DESCRIPTION_SILENT_489=Perform a quiet installation INFO_INSTALLDS_DESCRIPTION_SILENT_489=Run setup in quiet mode. Quiet mode \ will not output progress information to standard output INFO_INSTALLDS_DESCRIPTION_BASEDN_490=Specifies the base DN for user \ information in the Directory Server. Multiple base DNs may be provided by \ using this option multiple times opends/src/quicksetup/org/opends/quicksetup/QuickSetupLog.java
@@ -93,6 +93,8 @@ logger.setUseParentHandlers(false); logger = Logger.getLogger("org.opends.admin.ads"); logger.setUseParentHandlers(false); logger = Logger.getLogger("org.opends.server.tools"); logger.setUseParentHandlers(false); } /** opends/src/quicksetup/org/opends/quicksetup/installer/SetupLauncher.java
@@ -76,6 +76,7 @@ QuickSetupLog.initLogFileHandler( File.createTempFile(LOG_FILE_PREFIX, LOG_FILE_SUFFIX), "org.opends.quicksetup.installer"); QuickSetupLog.disableConsoleLogging(); } catch (Throwable t) { System.err.println("Unable to initialize log"); @@ -124,40 +125,49 @@ * {@inheritDoc} */ public void launch() { if (shouldPrintVersion()) // Validate user provided data try { if (!argParser.usageOrVersionDisplayed()) argParser.parseArguments(args); if (argParser.isVersionArgumentPresent()) { printVersion(); System.exit(ReturnCode.PRINT_VERSION.getReturnCode()); } System.exit(ReturnCode.PRINT_VERSION.getReturnCode()); } else if (shouldPrintUsage()) { if (!argParser.usageOrVersionDisplayed()) else if (argParser.isUsageArgumentPresent()) { printUsage(false); System.exit(ReturnCode.SUCCESSFUL.getReturnCode()); } System.exit(ReturnCode.SUCCESSFUL.getReturnCode()); } else if (isCli()) { System.exit(InstallDS.mainCLI(args)); } else { willLaunchGui(); int exitCode = launchGui(args); if (exitCode != 0) { File logFile = QuickSetupLog.getLogFile(); if (logFile != null) { guiLaunchFailed(logFile.toString()); } else { guiLaunchFailed(null); } else if (isCli()) { System.exit(InstallDS.mainCLI(args)); } else { willLaunchGui(); int exitCode = launchGui(args); if (exitCode != 0) { File logFile = QuickSetupLog.getLogFile(); if (logFile != null) { guiLaunchFailed(logFile.toString()); } else { guiLaunchFailed(null); } System.exit(InstallDS.mainCLI(args)); } } } catch (ArgumentException ae) { Message message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); System.err.println(message); System.err.println(); System.err.println(argParser.getUsage()); System.exit(ReturnCode.USER_DATA_ERROR.getReturnCode()); } } @@ -205,4 +215,11 @@ protected CliApplication createCliApplication() { return null; } } /** * {@inheritDoc} */ protected boolean isCli() { return argParser.isCli(); } } opends/src/server/org/opends/server/tools/InstallDS.java
@@ -30,7 +30,6 @@ import static org.opends.messages.AdminToolMessages.*; import static org.opends.messages.QuickSetupMessages.*; import static org.opends.messages.ToolMessages.*; import static org.opends.messages.UtilityMessages.*; import java.io.File; import java.io.InputStream; opends/src/server/org/opends/server/tools/InstallDSArgumentParser.java
@@ -66,6 +66,8 @@ BooleanArgument showUsageArg; BooleanArgument quietArg; BooleanArgument noPromptArg; StringArgument propertiesFileArgument; BooleanArgument noPropertiesFileArgument; BooleanArgument skipPortCheckArg; BooleanArgument enableWindowsServiceArg; BooleanArgument doNotStartArg; @@ -116,6 +118,7 @@ "test", 't', "testOnly", INFO_INSTALLDS_DESCRIPTION_TESTONLY.get()); testOnlyArg.setHidden(true); testOnlyArg.setPropertyName("testOnly"); addArgument(testOnlyArg); cliArg = new BooleanArgument( @@ -123,11 +126,12 @@ OPTION_SHORT_CLI, OPTION_LONG_CLI, INFO_INSTALLDS_DESCRIPTION_CLI.get()); cliArg.setPropertyName(OPTION_LONG_CLI); addArgument(cliArg); configFileArg = new StringArgument( "configfile", 'c', "configFile", false, false, true, "{configFile}", getDefaultConfigFile(), null, false, true, "{configFile}", getDefaultConfigFile(), "configFile", INFO_DESCRIPTION_CONFIG_FILE.get()); configFileArg.setHidden(true); addArgument(configFileArg); @@ -136,7 +140,7 @@ "configclass", OPTION_SHORT_CONFIG_CLASS, OPTION_LONG_CONFIG_CLASS, false, false, true, OPTION_VALUE_CONFIG_CLASS, ConfigFileHandler.class.getName(), null, ConfigFileHandler.class.getName(), OPTION_LONG_CONFIG_CLASS, INFO_DESCRIPTION_CONFIG_CLASS.get()); configClassArg.setHidden(true); addArgument(configClassArg); @@ -153,7 +157,7 @@ progNameArg = new StringArgument( "progname", 'P', "programName", false, false, true, "{programName}", defaultProgName, null, INFO_INSTALLDS_DESCRIPTION_PROGNAME.get()); "programName", INFO_INSTALLDS_DESCRIPTION_PROGNAME.get()); progNameArg.setHidden(true); addArgument(progNameArg); @@ -161,6 +165,7 @@ "quiet", OPTION_SHORT_QUIET, OPTION_LONG_QUIET, INFO_INSTALLDS_DESCRIPTION_SILENT.get()); quietArg.setPropertyName(OPTION_LONG_QUIET); addArgument(quietArg); noPromptArg = new BooleanArgument( @@ -168,44 +173,59 @@ OPTION_SHORT_NO_PROMPT, OPTION_LONG_NO_PROMPT, INFO_INSTALLDS_DESCRIPTION_NO_PROMPT.get()); noPromptArg.setPropertyName(OPTION_LONG_NO_PROMPT); addArgument(noPromptArg); propertiesFileArgument = new StringArgument( "propertiesFilePath", null, OPTION_LONG_PROP_FILE_PATH, false, false, true, OPTION_VALUE_PROP_FILE_PATH, null, null, INFO_DESCRIPTION_PROP_FILE_PATH.get()); addArgument(propertiesFileArgument); setFilePropertiesArgument(propertiesFileArgument); noPropertiesFileArgument = new BooleanArgument( "noPropertiesFileArgument", null, OPTION_LONG_NO_PROP_FILE, INFO_DESCRIPTION_NO_PROP_FILE.get()); addArgument(noPropertiesFileArgument); setNoPropertiesFileArgument(noPropertiesFileArgument); baseDNArg = new StringArgument( "basedn", OPTION_SHORT_BASEDN, OPTION_LONG_BASEDN, false, true, true, OPTION_VALUE_BASEDN, "dc=example,dc=com", null, "dc=example,dc=com", OPTION_LONG_BASEDN, INFO_INSTALLDS_DESCRIPTION_BASEDN.get()); addArgument(baseDNArg); addBaseEntryArg = new BooleanArgument( "addbase", 'a', "addBaseEntry", INFO_INSTALLDS_DESCRIPTION_ADDBASE.get()); addBaseEntryArg.setPropertyName("addBaseEntry"); addArgument(addBaseEntryArg); importLDIFArg = new StringArgument( "importldif", OPTION_SHORT_LDIF_FILE, OPTION_LONG_LDIF_FILE, false, true, true, OPTION_VALUE_LDIF_FILE, null, null, null, OPTION_LONG_LDIF_FILE, INFO_INSTALLDS_DESCRIPTION_IMPORTLDIF.get()); addArgument(importLDIFArg); rejectedImportFileArg = new StringArgument( "rejectfile", 'R', "rejectFile", false, false, true, "{rejectFile}", null, null, true, "{rejectFile}", null, "rejectFile", INFO_INSTALLDS_DESCRIPTION_REJECTED_FILE.get()); addArgument(rejectedImportFileArg); skippedImportFileArg = new StringArgument( "skipFile", null, "skipFile", false, false, true, "{skipFile}", null, null, true, "{skipFile}", null, "skipFile", INFO_INSTALLDS_DESCRIPTION_SKIPPED_FILE.get()); addArgument(skippedImportFileArg); sampleDataArg = new IntegerArgument( "sampledata", 'd', "sampleData", false, false, true, "{numEntries}", 0, null, false, true, "{numEntries}", 0, "sampleData", true, 0, false, 0, INFO_INSTALLDS_DESCRIPTION_SAMPLE_DATA.get()); addArgument(sampleDataArg); @@ -219,14 +239,14 @@ "ldapport", OPTION_SHORT_PORT, "ldapPort", false, false, true, OPTION_VALUE_PORT, defaultPort, null, true, 1, true, 65535, "ldapPort", true, 1, true, 65535, INFO_INSTALLDS_DESCRIPTION_LDAPPORT.get()); addArgument(ldapPortArg); jmxPortArg = new IntegerArgument( "jmxport", 'x', "jmxPort", false, false, true, "{jmxPort}", SetupUtils.getDefaultJMXPort(), null, true, SetupUtils.getDefaultJMXPort(), "jmxPort", true, 1, true, 65535, INFO_INSTALLDS_DESCRIPTION_JMXPORT.get()); addArgument(jmxPortArg); @@ -234,6 +254,7 @@ skipPortCheckArg = new BooleanArgument( "skipportcheck", 'S', "skipPortCheck", INFO_INSTALLDS_DESCRIPTION_SKIPPORT.get()); skipPortCheckArg.setPropertyName("skipPortCheck"); addArgument(skipPortCheckArg); directoryManagerDNArg = new StringArgument( @@ -241,7 +262,7 @@ OPTION_LONG_ROOT_USER_DN, false, false, true, OPTION_VALUE_ROOT_USER_DN, "cn=Directory Manager", null, INFO_INSTALLDS_DESCRIPTION_ROOTDN.get()); OPTION_LONG_ROOT_USER_DN, INFO_INSTALLDS_DESCRIPTION_ROOTDN.get()); addArgument(directoryManagerDNArg); directoryManagerPwdStringArg = new StringArgument( @@ -249,7 +270,7 @@ "rootUserPassword", false, false, true, "{password}", null, null, "rootUserPassword", INFO_INSTALLDS_DESCRIPTION_ROOTPW.get()); addArgument(directoryManagerPwdStringArg); @@ -258,26 +279,30 @@ OPTION_SHORT_BINDPWD_FILE, "rootUserPasswordFile", false, false, OPTION_VALUE_BINDPWD_FILE, null, null, INFO_INSTALLDS_DESCRIPTION_ROOTPWFILE.get()); null, "rootUserPasswordFile", INFO_INSTALLDS_DESCRIPTION_ROOTPWFILE.get()); addArgument(directoryManagerPwdFileArg); enableWindowsServiceArg = new BooleanArgument( "enablewindowsservice", 'e', "enableWindowsService", INFO_INSTALLDS_DESCRIPTION_ENABLE_WINDOWS_SERVICE.get()); enableWindowsServiceArg.setPropertyName("enableWindowsService"); if (SetupUtils.isWindows()) { addArgument(enableWindowsServiceArg); } doNotStartArg = new BooleanArgument( "donotstart", 'O', "donotstart", "donotstart", 'O', "doNotStart", INFO_INSTALLDS_DESCRIPTION_DO_NOT_START.get()); doNotStartArg.setPropertyName("doNotStart"); addArgument(doNotStartArg); enableStartTLSArg = new BooleanArgument( "enableStartTLS", OPTION_SHORT_START_TLS, "enableStartTLS", INFO_INSTALLDS_DESCRIPTION_ENABLE_STARTTLS.get()); enableStartTLSArg.setPropertyName("enableStartTLS"); addArgument(enableStartTLSArg); int defaultSecurePort = UserData.getDefaultSslPort(defaultPort); @@ -289,7 +314,7 @@ "ldapsport", OPTION_SHORT_USE_SSL, "ldapsPort", false, false, true, OPTION_VALUE_PORT, defaultSecurePort, null, true, 1, true, 65535, "ldapsPort", true, 1, true, 65535, INFO_INSTALLDS_DESCRIPTION_LDAPSPORT.get()); addArgument(ldapsPortArg); @@ -297,41 +322,46 @@ "generateSelfSignedCertificate", null, "generateSelfSignedCertificate", INFO_INSTALLDS_DESCRIPTION_USE_SELF_SIGNED.get()); generateSelfSignedCertificateArg.setPropertyName( "generateSelfSignedCertificate"); addArgument(generateSelfSignedCertificateArg); usePkcs11Arg = new BooleanArgument("usePkcs11Keystore", null, "usePkcs11Keystore", INFO_INSTALLDS_DESCRIPTION_USE_PKCS11.get()); usePkcs11Arg.setPropertyName("usePkcs11Keystore"); addArgument(usePkcs11Arg); useJavaKeyStoreArg = new StringArgument("useJavaKeystore", null, "useJavaKeystore", false, false, true, OPTION_VALUE_KEYSTOREPATH, null, null, true, OPTION_VALUE_KEYSTOREPATH, null, "useJavaKeystore", INFO_INSTALLDS_DESCRIPTION_USE_JAVAKEYSTORE.get()); addArgument(useJavaKeyStoreArg); usePkcs12Arg = new StringArgument("usePkcs12keyStore", null, "usePkcs12keyStore", false, false, true, OPTION_VALUE_KEYSTOREPATH, null, null, true, OPTION_VALUE_KEYSTOREPATH, null, "usePkcs12keyStore", INFO_INSTALLDS_DESCRIPTION_USE_PKCS12.get()); addArgument(usePkcs12Arg); keyStorePasswordArg = new StringArgument("keystorePassword", OPTION_SHORT_KEYSTORE_PWD, OPTION_LONG_KEYSTORE_PWD, false, false, true, OPTION_VALUE_KEYSTORE_PWD, null, null, OPTION_VALUE_KEYSTORE_PWD, null, OPTION_LONG_KEYSTORE_PWD, INFO_INSTALLDS_DESCRIPTION_KEYSTOREPASSWORD.get()); addDefaultArgument(keyStorePasswordArg); keyStorePasswordFileArg = new FileBasedArgument("keystorePasswordFile", OPTION_SHORT_KEYSTORE_PWD_FILE, OPTION_LONG_KEYSTORE_PWD_FILE, false, false, OPTION_VALUE_KEYSTORE_PWD_FILE, null, null, false, OPTION_VALUE_KEYSTORE_PWD_FILE, null, OPTION_LONG_KEYSTORE_PWD_FILE, INFO_INSTALLDS_DESCRIPTION_KEYSTOREPASSWORD_FILE.get()); addDefaultArgument(keyStorePasswordFileArg); certNicknameArg = new StringArgument("certnickname", OPTION_SHORT_CERT_NICKNAME, OPTION_LONG_CERT_NICKNAME, false, false, true, OPTION_VALUE_CERT_NICKNAME, null, null, false, false, true, OPTION_VALUE_CERT_NICKNAME, null, OPTION_LONG_CERT_NICKNAME, INFO_INSTALLDS_DESCRIPTION_CERT_NICKNAME.get()); addDefaultArgument(certNicknameArg); @@ -343,6 +373,16 @@ } /** * Returns whether the command was launched in CLI mode or not. * @return <CODE>true</CODE> if the command was launched to use CLI mode and * <CODE>false</CODE> otherwise. */ public boolean isCli() { return cliArg.isPresent(); } /** * {@inheritDoc} */ @Override() @@ -359,18 +399,21 @@ errorMessages.add(ae.getMessageObject()); } checkConfigFileArg(errorMessages); checkServerPassword(errorMessages); checkProvidedPorts(errorMessages); checkImportDataArguments(errorMessages); checkSecurityArguments(errorMessages); if (errorMessages.size() > 0) if (!isUsageArgumentPresent() && !isVersionArgumentPresent()) { Message message = ERR_CANNOT_INITIALIZE_ARGS.get( Utils.getMessageFromCollection(errorMessages, Constants.LINE_SEPARATOR)); throw new ArgumentException(message); checkConfigFileArg(errorMessages); checkServerPassword(errorMessages); checkProvidedPorts(errorMessages); checkImportDataArguments(errorMessages); checkSecurityArguments(errorMessages); if (errorMessages.size() > 0) { Message message = ERR_CANNOT_INITIALIZE_ARGS.get( Utils.getMessageFromCollection(errorMessages, Constants.LINE_SEPARATOR)); throw new ArgumentException(message); } } } opends/src/server/org/opends/server/util/args/ArgumentParser.java
@@ -93,6 +93,9 @@ // Indicates whether the usage or version information has been displayed. private boolean usageOrVersionDisplayed; // Indicates whether the version argument was provided. private boolean versionPresent; // The set of arguments defined for this parser, referenced by short ID. private HashMap<Character,Argument> shortIDMap; @@ -198,6 +201,7 @@ longIDMap = new HashMap<String,Argument>(); allowsTrailingArguments = false; usageOrVersionDisplayed = false; versionPresent = false; trailingArgsDisplayName = null; maxTrailingArguments = 0; minTrailingArguments = 0; @@ -265,6 +269,7 @@ longIDMap = new HashMap<String,Argument>(); trailingArguments = new ArrayList<String>(); usageOrVersionDisplayed = false; versionPresent = false; rawArguments = null; usageArgument = null; usageOutputStream = System.out; @@ -881,6 +886,7 @@ // "--version" will always be interpreted as requesting version // information. usageOrVersionDisplayed = true; versionPresent = true; try { DirectoryServer.printVersion(usageOutputStream); @@ -1007,6 +1013,7 @@ // version information except if it's already defined (e.g in // ldap tools). usageOrVersionDisplayed = true ; versionPresent = true; try { DirectoryServer.printVersion(usageOutputStream); @@ -1763,5 +1770,31 @@ return general; } /** * Returns whether the usage argument was provided or not. This method * should be called after a call to parseArguments. * @return <CODE>true</CODE> if the usage argument was provided and * <CODE>false</CODE> otherwise. */ public boolean isUsageArgumentPresent() { boolean isUsageArgumentPresent = false; if (usageArgument != null) { isUsageArgumentPresent = usageArgument.isPresent(); } return isUsageArgumentPresent; } /** * Returns whether the version argument was provided or not. This method * should be called after a call to parseArguments. * @return <CODE>true</CODE> if the version argument was provided and * <CODE>false</CODE> otherwise. */ public boolean isVersionArgumentPresent() { return versionPresent; } } opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java
@@ -118,6 +118,9 @@ // The subcommand requested by the user as part of the command-line arguments. private SubCommand subCommand; //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; @@ -810,6 +813,7 @@ // information. try { versionPresent = true; DirectoryServer.printVersion(usageOutputStream); usageOrVersionDisplayed = true ; } catch (Exception e) {} @@ -847,6 +851,7 @@ // information. try { versionPresent = true; DirectoryServer.printVersion(usageOutputStream); usageOrVersionDisplayed = true ; } catch (Exception e) {} @@ -990,6 +995,7 @@ if (dashVAccepted) { usageOrVersionDisplayed = true; versionPresent = true; try { DirectoryServer.printVersion(usageOutputStream); @@ -1057,6 +1063,7 @@ if (dashVAccepted) { usageOrVersionDisplayed = true; versionPresent = true; try { DirectoryServer.printVersion(usageOutputStream); @@ -1947,5 +1954,41 @@ } } } /** * Returns whether the usage argument was provided or not. This method * should be called after a call to parseArguments. * @return <CODE>true</CODE> if the usage argument was provided and * <CODE>false</CODE> otherwise. */ public boolean isUsageArgumentPresent() { boolean isUsageArgumentPresent = false; if (usageArgument != null) { isUsageArgumentPresent = usageArgument.isPresent(); } return isUsageArgumentPresent; } /** * Returns whether the version argument was provided or not. This method * should be called after a call to parseArguments. * @return <CODE>true</CODE> if the version argument was provided and * <CODE>false</CODE> otherwise. */ public boolean isVersionArgumentPresent() { boolean isPresent; if (!super.isVersionArgumentPresent()) { isPresent = versionPresent; } else { isPresent = true; } return isPresent; } }