< prev index next >
src/jdk.jcmd/share/classes/sun/tools/jstat/Arguments.java
Print this page
rev 48495 : 8189102: All tools should support -?, -h and --help
Reviewed-by: kvn, jjg, weijun, alanb, rfield, ksrini
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -71,11 +71,11 @@
private String vmIdString;
private VmIdentifier vmId;
public static void printUsage(PrintStream ps) {
- ps.println("Usage: jstat -help|-options");
+ ps.println("Usage: jstat --help|-options");
ps.println(" jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]");
ps.println();
ps.println("Definitions:");
ps.println(" <option> An option reported by the -options option");
ps.println(" <vmid> Virtual Machine Identifier. A vmid takes the following form:");
@@ -91,20 +91,23 @@
ps.println(" <n>[\"ms\"|\"s\"]");
ps.println(" Where <n> is an integer and the suffix specifies the units as ");
ps.println(" milliseconds(\"ms\") or seconds(\"s\"). The default units are \"ms\".");
ps.println(" <count> Number of samples to take before terminating.");
ps.println(" -J<flag> Pass <flag> directly to the runtime system.");
+ ps.println(" -? -h --help Prints this help message.");
+ ps.println(" -help Prints this help message.");
// undocumented options:
// -list [<vmid>] - list counter names
// -snap <vmid> - snapshot counter values as name=value pairs
// -name <pattern> - output counters matching given pattern
// -a - sort in ascending order (default)
// -d - sort in descending order
// -v - verbose output (-snap)
// -constants - output constants with -name output
// -strings - output strings with -name output
+ // -help - same as -? ...
}
private static int toMillis(String s) throws IllegalArgumentException {
String[] unitStrings = { "ms", "s" }; // ordered from most specific to
@@ -145,10 +148,13 @@
help = true;
return;
}
if ((args[0].compareTo("-?") == 0)
+ || (args[0].compareTo("-h") == 0)
+ || (args[0].compareTo("--help") == 0)
+ // -help: legacy.
|| (args[0].compareTo("-help") == 0)) {
help = true;
return;
} else if (args[0].compareTo("-options") == 0) {
options = true;
< prev index next >