Skip to content

Commit bf87264

Browse files
committed
[bugfix] Show the correct application name in the Usage help at the CLI
1 parent 3b5357d commit bf87264

File tree

9 files changed

+60
-5
lines changed

9 files changed

+60
-5
lines changed

exist-core/src/main/java/org/exist/backup/ExportGUI.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.exist.util.Configuration;
3232
import org.exist.util.MimeTable;
3333
import org.exist.util.MimeType;
34+
import org.exist.util.OSUtil;
3435
import org.exist.util.SystemExitCodes;
3536
import org.exist.xquery.TerminatedException;
3637
import se.softhouse.jargo.Argument;
@@ -624,6 +625,7 @@ public static void main(final String[] args) {
624625
// parse command-line options
625626
CommandLineParser
626627
.withArguments(helpArg)
628+
.programName("export-gui" + (OSUtil.isWindows() ? ".bat" : ".sh"))
627629
.parse(args);
628630

629631
} catch (final StartException e) {

exist-core/src/main/java/org/exist/backup/ExportMain.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.exist.storage.txn.Txn;
3131
import org.exist.util.Configuration;
3232
import org.exist.util.DatabaseConfigurationException;
33+
import org.exist.util.OSUtil;
3334
import org.exist.util.SystemExitCodes;
3435
import org.exist.xquery.TerminatedException;
3536
import se.softhouse.jargo.Argument;
@@ -130,6 +131,7 @@ public static void main(final String[] args) {
130131
.withArguments(noCheckArg, checkDocsArg, directAccessArg, exportArg, noExportArg, incrementalArg, zipArg, noZipArg)
131132
.andArguments(configArg, outputDirArg)
132133
.andArguments(helpArg, verboseArg)
134+
.programName("export" + (OSUtil.isWindows() ? ".bat" : ".sh"))
133135
.parse(args);
134136

135137
process(arguments);

exist-core/src/main/java/org/exist/backup/Main.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.exist.start.StartException;
2727
import org.exist.util.ConfigurationHelper;
2828
import org.exist.util.NamedThreadFactory;
29+
import org.exist.util.OSUtil;
2930
import org.exist.util.SystemExitCodes;
3031
import org.exist.xmldb.*;
3132
import org.xmldb.api.DatabaseManager;
@@ -461,6 +462,7 @@ public static void main(final String[] args) {
461462
.andArguments(backupCollectionArg, backupOutputDirArg, backupDeduplicateBlobs)
462463
.andArguments(restoreArg, rebuildExpathRepoArg, overwriteAppsArg)
463464
.andArguments(helpArg, guiArg, quietArg, optionArg)
465+
.programName("backup" + (OSUtil.isWindows() ? ".bat" : ".sh"))
464466
.parse(args);
465467

466468
process(arguments);

exist-core/src/main/java/org/exist/client/CommandlineOptions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.nio.file.Path;
2727
import java.util.*;
2828

29+
import org.exist.util.OSUtil;
2930
import org.exist.xmldb.XmldbURI;
3031
import org.exist.xquery.util.URIUtils;
3132
import se.softhouse.jargo.*;
@@ -176,6 +177,7 @@ public static CommandlineOptions parse(final String[] args) throws ArgumentExcep
176177
.andArguments(setDocArg, xupdateArg)
177178
.andArguments(reindexArg, reindexRecurseDirsArg)
178179
.andArguments(helpArg, quietArg, verboseArg, outputFileArg, optionArg)
180+
.programName("client" + (OSUtil.isWindows() ? ".bat" : ".sh"))
179181
.parse(args);
180182

181183
final boolean quiet = getBool(arguments, quietArg);

exist-core/src/main/java/org/exist/jetty/JettyStart.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@
4141
import org.exist.start.Main;
4242
import org.exist.start.StartException;
4343
import org.exist.storage.BrokerPool;
44-
import org.exist.util.ConfigurationHelper;
45-
import org.exist.util.FileUtils;
46-
import org.exist.util.SingleInstanceConfiguration;
47-
import org.exist.util.SystemExitCodes;
44+
import org.exist.util.*;
4845
import org.exist.validation.XmlLibraryChecker;
4946
import org.exist.xmldb.DatabaseImpl;
5047
import org.exist.xmldb.ShutdownListener;
@@ -106,6 +103,7 @@ public static void main(final String[] args) {
106103

107104
CommandLineParser
108105
.withArguments(helpArg)
106+
.programName("startup" + (OSUtil.isWindows() ? ".bat" : ".sh"))
109107
.parse(args);
110108

111109
} catch (final StartException e) {

exist-core/src/main/java/org/exist/jetty/ServerShutdown.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.exist.start.CompatibleJavaVersionCheck;
2727
import org.exist.start.StartException;
2828
import org.exist.util.ConfigurationHelper;
29+
import org.exist.util.OSUtil;
2930
import org.exist.util.SystemExitCodes;
3031
import org.exist.xmldb.DatabaseInstanceManager;
3132
import org.exist.xmldb.XmldbURI;
@@ -77,6 +78,7 @@ public static void main(final String[] args) {
7778
final ParsedArguments arguments = CommandLineParser
7879
.withArguments(userArg, passwordArg, uriArg)
7980
.andArguments(helpArg)
81+
.programName("shutdown" + (OSUtil.isWindows() ? ".bat" : ".sh"))
8082
.parse(args);
8183

8284
process(arguments);

exist-core/src/main/java/org/exist/launcher/LauncherWrapper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.exist.start.CompatibleJavaVersionCheck;
2525
import org.exist.start.StartException;
2626
import org.exist.util.ConfigurationHelper;
27+
import org.exist.util.OSUtil;
2728
import org.exist.util.SystemExitCodes;
2829
import se.softhouse.jargo.Argument;
2930
import se.softhouse.jargo.ArgumentException;
@@ -54,7 +55,7 @@
5455
public class LauncherWrapper {
5556

5657
private final static String LAUNCHER = org.exist.launcher.Launcher.class.getName();
57-
private final static String OS = System.getProperty("os.name").toLowerCase();
58+
private final static String OS = OSUtil.getOS().toLowerCase();
5859

5960
/* general arguments */
6061
private static final Argument<?> helpArg = helpArgument("-h", "--help");
@@ -66,6 +67,7 @@ public final static void main(final String[] args) {
6667
// parse command-line options
6768
CommandLineParser
6869
.withArguments(helpArg)
70+
.programName("launcher" + (OSUtil.isWindows() ? ".bat" : ".sh"))
6971
.parse(args);
7072

7173
} catch (final StartException e) {

exist-core/src/main/java/org/exist/management/client/JMXClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import org.exist.start.CompatibleJavaVersionCheck;
2525
import org.exist.start.StartException;
26+
import org.exist.util.OSUtil;
2627
import org.exist.util.SystemExitCodes;
2728
import se.softhouse.jargo.Argument;
2829
import se.softhouse.jargo.ArgumentException;
@@ -314,6 +315,7 @@ public static void main(final String[] args) {
314315
.andArguments(cacheDisplayArg, locksDisplayArg)
315316
.andArguments(dbInfoArg, memoryInfoArg, sanityCheckInfoArg, jobsInfoArg)
316317
.andArguments(helpArg)
318+
.programName("jmxclient" + (OSUtil.isWindows() ? ".bat" : ".sh"))
317319
.parse(args);
318320

319321
process(arguments);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* eXist-db Open Source Native XML Database
3+
* Copyright (C) 2001 The eXist-db Authors
4+
*
5+
6+
* http://www.exist-db.org
7+
*
8+
* This library is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU Lesser General Public
10+
* License as published by the Free Software Foundation; either
11+
* version 2.1 of the License, or (at your option) any later version.
12+
*
13+
* This library is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
* Lesser General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public
19+
* License along with this library; if not, write to the Free Software
20+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
*/
22+
package org.exist.util;
23+
24+
public interface OSUtil {
25+
26+
/**
27+
* Return true if the Operating System is Microsoft Windows.
28+
*
29+
* @return true if the OS is Windows.
30+
*/
31+
static boolean isWindows() {
32+
return getOS().toLowerCase().contains("win");
33+
}
34+
35+
/**
36+
* Return the OS name from the `os.name` System Property.
37+
*
38+
* @return the OS name or "unknown".
39+
*/
40+
static String getOS() {
41+
return System.getProperty("os.name", "unknown");
42+
}
43+
}

0 commit comments

Comments
 (0)