Skip to content

Commit 84027da

Browse files
committed
fix(config): add deprecated hints to --help output for CLI params
Mark deprecated options with "(deprecated)" in help text and add a note below the Usage line that positional seedNode args are deprecated.
1 parent f55e9cf commit 84027da

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

  • framework/src/main/java/org/tron/core/config/args

framework/src/main/java/org/tron/core/config/args/Args.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,9 @@ public static void printHelp(JCommander jCommander) {
16981698
jCommander.getProgramName();
16991699
helpStr.append(String.format("%nUsage: java -jar %s [options] [seedNode <seedNode> ...]%n",
17001700
programName));
1701+
helpStr.append(String.format(
1702+
"%nNote: Positional seedNode arguments are deprecated."
1703+
+ " Use seed.node.ip.list in the config file instead.%n"));
17011704
helpStr.append(String.format("%nVERSION: %n%s-%s%n", Version.getVersion(),
17021705
getCommitIdAbbrev()));
17031706

@@ -1719,9 +1722,21 @@ public static void printHelp(JCommander jCommander) {
17191722
logger.warn("Miss option:{}", option);
17201723
continue;
17211724
}
1725+
boolean isDeprecated;
1726+
try {
1727+
isDeprecated = CLIParameter.class.getDeclaredField(
1728+
parameterDescription.getParameterized().getName())
1729+
.isAnnotationPresent(Deprecated.class);
1730+
} catch (NoSuchFieldException e) {
1731+
isDeprecated = false;
1732+
}
1733+
String desc = upperFirst(parameterDescription.getDescription());
1734+
if (isDeprecated) {
1735+
desc += " (deprecated)";
1736+
}
17221737
String tmpOptionDesc = String.format("%s\t\t\t%s%n",
17231738
Strings.padEnd(parameterDescription.getNames(), optionMaxLength, ' '),
1724-
upperFirst(parameterDescription.getDescription()));
1739+
desc);
17251740
helpStr.append(tmpOptionDesc);
17261741
}
17271742
}

0 commit comments

Comments
 (0)