balodesecurity opened a new pull request, #8324:
URL: https://github.com/apache/hadoop/pull/8324

   ## Summary
   
   `hdfs diskbalancer -help plan` (and `-help execute`, `-help query`, `-help 
cancel`, `-help report`) always printed the generic usage summary instead of 
the per-command help text. This is a regression compared to Hadoop 3.1.1.
   
   ### Root Cause
   
   The `--help` option is declared with `.optionalArg(true)` in Apache Commons 
CLI. With that flag, the option value is **only** captured when the equals-sign 
form is used (`--help=plan`). A space-separated form (`-help plan`) leaves 
`plan` as a positional leftover argument, so `cmd.getOptionValue("help")` 
returns `null` and `HelpCommand` falls through to printing generic help.
   
   ### Fix
   
   In `HelpCommand.execute()`, after `getOptionValue("help")` returns null, 
fall back to the first element of `cmd.getArgs()` as the sub-command name. This 
makes the natural `hdfs diskbalancer -help <cmd>` syntax work without requiring 
the awkward `--help=<cmd>` form.
   
   ### Changes
   
   - `HelpCommand.java`: add fallback to `cmd.getArgs()[0]` when the option 
value is null.
   - `TestDiskBalancerCommand.java`: add `testHelpCommandWithSubCommand` which 
runs `-help <cmd>` for all five sub-commands and asserts the output contains 
the expected keyword.
   
   ## Test plan
   - [ ] `TestDiskBalancerCommand#testHelpCommandWithSubCommand` passes locally 
✅
   - [ ] Full module build passes (`mvn package ... -DskipTests`) ✅
   - [ ] Existing `testHelpCommand` (no sub-command) still passes ✅


-- 
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]

Reply via email to