yuruguo commented on a change in pull request #12535:
URL: https://github.com/apache/pulsar/pull/12535#discussion_r743502350
##########
File path:
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdSchemas.java
##########
@@ -51,13 +52,24 @@ public CmdSchemas(Supplier<PulsarAdmin> admin) {
@Parameter(names = { "--version" }, description = "version", required
= false)
private Long version;
+ @Parameter(names = {"--all"}, description = "all version", required =
false)
+ private boolean all = false;
+
@Override
void run() throws Exception {
String topic = validateTopicName(params);
- if (version == null) {
+ if (version != null && all) {
+ throw new ParameterException("Only one or neither of --version
and --all can be specified.");
+ }
+ if (version == null && !all) {
System.out.println(getAdmin().schemas().getSchemaInfoWithVersion(topic));
- } else {
+ } else if (!all) {
+ if (version < 0) {
+ throw new ParameterException("Option --version must be
greater than 0, but found " + version);
+ }
System.out.println(getAdmin().schemas().getSchemaInfo(topic,
version));
+ } else {
+ System.out.println(getAdmin().schemas().getAllSchemas(topic));
Review comment:
It may be a better way to print the schemas in the list one by one. If
approved, I will modify the code
##########
File path:
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdSchemas.java
##########
@@ -51,13 +52,24 @@ public CmdSchemas(Supplier<PulsarAdmin> admin) {
@Parameter(names = { "--version" }, description = "version", required
= false)
private Long version;
+ @Parameter(names = {"--all"}, description = "all version", required =
false)
+ private boolean all = false;
+
@Override
void run() throws Exception {
String topic = validateTopicName(params);
- if (version == null) {
+ if (version != null && all) {
+ throw new ParameterException("Only one or neither of --version
and --all can be specified.");
+ }
+ if (version == null && !all) {
System.out.println(getAdmin().schemas().getSchemaInfoWithVersion(topic));
- } else {
+ } else if (!all) {
+ if (version < 0) {
+ throw new ParameterException("Option --version must be
greater than 0, but found " + version);
+ }
System.out.println(getAdmin().schemas().getSchemaInfo(topic,
version));
+ } else {
+ System.out.println(getAdmin().schemas().getAllSchemas(topic));
Review comment:
It may be a better way to print the schemas in the list one by one. If
agree, I will modify the code
--
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]