vrajat opened a new pull request, #14419:
URL: https://github.com/apache/pinot/pull/14419
Currently `pinot-admin` command help either throws an NPE or executes the
command. Example:
```
pinot-admin.sh GenerateData --help
2024/11/11 12:04:07.820 INFO [GenerateDataCommand] [main] Executing command:
GenerateData -numRecords 0 -numFiles 0 -schemaFile null -outDir null
-schemaAnnotationFile null
java.lang.NullPointerException
at java.base/java.io.File.<init>(File.java:278)
at
org.apache.pinot.tools.admin.command.GenerateDataCommand.execute(GenerateDataCommand.java:122)
at org.apache.pinot.tools.Command.call(Command.java:33)
at org.apache.pinot.tools.Command.call(Command.java:29)
at picocli.CommandLine.executeUserObject(CommandLine.java:2045)
at picocli.CommandLine.access$1500(CommandLine.java:148)
at
picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2457)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2419)
at
picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
at picocli.CommandLine.execute(CommandLine.java:2174)
at
org.apache.pinot.tools.admin.PinotAdministrator.execute(PinotAdministrator.java:173)
at
org.apache.pinot.tools.admin.PinotAdministrator.main(PinotAdministrator.java:204)
pinot-admin.sh AddTable --help
2024/11/11 11:58:58.253 WARN [AddTableCommand] [main] Dry Running Command:
AddTable -tableConfigFile null -offlineTableConfigFile null
-realtimeTableConfigFile null -schemaFile null -controllerProtocol http
-controllerHost null -controllerPort 9000 -controllerProtocol http -database
null -user null -password [hidden]
2024/11/11 11:58:58.253 WARN [AddTableCommand] [main] Use the -exec option
to actually execute the command.
```
This is because the help code was not moved to use picocli in
https://github.com/vrajat/pinot/commit/d7c0944ad76b02ca8a695caa3f0205b3c7a8b49a
This commit removes the old code to display the help message and uses
Picocli to generate it. With the change help message examples are:
```
❯ ./build/bin/pinot-admin.sh GenerateData --help
Usage: <main class> GenerateData [-hV] [-overwrite] -numFiles=<_numFiles>
-numRecords=<_numRecords> -outDir=<_outDir>
[-schemaAnnotationFile=<_schemaAnnFile>]
-schemaFile=<_schemaFile>
[-format=<_format>]
-h, --help Show this help message and exit.
-numFiles=<_numFiles>
Number of files to generate.
-numRecords=<_numRecords>
Number of records to generate.
-outDir=<_outDir> Directory where data would be generated.
-overwrite Overwrite, if directory exists
-schemaAnnotationFile=<_schemaAnnFile>
File containing dim/metrics for columns.
-schemaFile=<_schemaFile>
File containing schema for data.
-V, --version Print version information and exit.
-format=<_format> Output format ('AVRO' or 'CSV' or 'JSON').
❯ ./build/bin/pinot-admin.sh AddTable --help
Usage: <main class> AddTable [-hV] [-exec] [-skipControllerCertValidation]
[-update] [-authToken=<_authToken>]
[-authTokenUrl=<_authTokenUrl>]
[-controllerHost=<_controllerHost>]
[-controllerPort=<_controllerPort>]
[-controllerProtocol=<_controllerProtocol>]
[-database=<_database>]
[-filePath=<_tableConfigFile>]
[-offlineFilePath=<_offlineTableConfigFile>]
[-password=<_password>]
[-realtimeFilePath=<_realtimeTableConfigFile>]
[-schema=<_schemaFile>] [-user=<_user>]
-authToken=<_authToken>
Http auth token.
-authTokenUrl=<_authTokenUrl>
Http auth token url.
-controllerHost=<_controllerHost>
Host name for controller.
-controllerPort=<_controllerPort>
Port number for controller.
-controllerProtocol=<_controllerProtocol>
Protocol for controller.
-database=<_database>
Corresponding database.
-exec Execute the command.
-filePath, -tableConf, -tableConfig,
-tableConfigFile=<_tableConfigFile>
Path to table config file.
-h, --help Show this help message and exit.
-offlineFilePath, -offlineTableConf, -offlineTableConfig,
-offlineTableConfigFile=<_offlineTableConfigFile>
Path to offline table config file.
-password=<_password>
Password for basic auth.
-realtimeFilePath, -realtimeTableConf, -realtimeTableConfig,
-realtimeTableConfigFile=<_realtimeTableConfigFile>
Path to realtime table config file.
-schema, -schemaFile, -schemaFileName=<_schemaFile>
Path to table schema file.
-skipControllerCertValidation
Whether to skip controller certification validation.
-update Update the existing table instead of creating new one
-user=<_user> Username for basic auth.
-V, --version Print version information and exit.
```
Moreover, picocli color codes the message if the terminal supports it.

While the diff is big, most of the diff adds a mixin as specified in
https://picocli.info/#_printing_help_automatically AND it removes the old help
message option. The picocli message is more helpful.
A test has also been added to make sure the changes are correct.
--
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]