slfan1989 commented on code in PR #5766:
URL: https://github.com/apache/hadoop/pull/5766#discussion_r1241044630
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestRouterCLI.java:
##########
@@ -120,7 +122,10 @@ public void testDeregisterSubCluster() throws Exception {
ByteArrayOutputStream dataOut = new ByteArrayOutputStream();
System.setOut(new PrintStream(dataOut));
oldOutPrintStream.println(dataOut);
- String[] args = {"-deregisterSubCluster", "-c", "SC-1"};
+ String[] args = {"-deregisterSubCluster", "-sc", "SC-1"};
Review Comment:
Thanks for your question! You are correct that in general, a single
character follows the hyphen "-". Our short option hopes to express
`subcluster`, maybe `sc` is better than `c`?
- RouterCLI#handleDeregisterSubCluster
```
private static final String OPTION_SC = "sc";
private static final String OPTION_SUBCLUSTERID = "subClusterId";
Option subClusterOpt = new Option(OPTION_SC, OPTION_SUBCLUSTERID, true,
"The subCluster can be specified using either the '-sc' or
'--subCluster' option. " +
" If the subCluster's Heartbeat Timeout, it will be marked as
'SC_LOST'.");
```
- org.apache.commons.cli.Option
For Options, we set short options using a hyphen `-` and long options using
two hyphens `--` when using the command.
```
/**
* Creates an Option using the specified parameters.
*
* @param option short representation of the option
* @param longOption the long representation of the option
* @param hasArg specifies whether the Option takes an argument or not
* @param description describes the function of the option
*
* @throws IllegalArgumentException if there are any non valid Option
characters in {@code opt}.
*/
public Option(final String option, final String longOption, final
boolean hasArg, final String description) throws IllegalArgumentException {
// ensure that the option is valid
this.option = OptionValidator.validate(option);
this.longOption = longOption;
// if hasArg is set then the number of arguments is 1
if (hasArg) {
this.argCount = 1;
}
this.description = description;
}
```
Our short option is set as `sc`, so it should be used as `-sc` when using
the command. The long option is set as `subClusterId`, so it should be used as
`--subClusterId` when using the command.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]