Mmuzaf commented on code in PR #2497: URL: https://github.com/apache/cassandra/pull/2497#discussion_r2204598272
########## src/java/org/apache/cassandra/tools/nodetool/GetEndpoints.java: ########## @@ -17,26 +17,38 @@ */ package org.apache.cassandra.tools.nodetool; -import static com.google.common.base.Preconditions.checkArgument; -import io.airlift.airline.Arguments; -import io.airlift.airline.Command; - import java.net.InetAddress; import java.util.ArrayList; import java.util.List; import org.apache.cassandra.tools.NodeProbe; -import org.apache.cassandra.tools.NodeTool.NodeToolCmd; +import org.apache.cassandra.tools.nodetool.layout.CassandraUsage; +import picocli.CommandLine.Parameters; +import picocli.CommandLine.Command; + +import static com.google.common.base.Preconditions.checkArgument; +import static org.apache.cassandra.tools.nodetool.CommandUtils.concatArgs; @Command(name = "getendpoints", description = "Print the end points that owns the key") -public class GetEndpoints extends NodeToolCmd +public class GetEndpoints extends WithPortDisplayAbstractCommand { - @Arguments(usage = "<keyspace> <table> <key>", description = "The keyspace, the table, and the partition key for which we need to find the endpoint") + @CassandraUsage(usage = "<keyspace> <table> <key>", description = "The keyspace, the table, and the partition key for which we need to find the endpoint") private List<String> args = new ArrayList<>(); + @Parameters(index = "0", arity = "0..1", description = "The keyspace for which we need to find the endpoint") Review Comment: I've made these arguments "unmandatory" (`arity=0..1`) so that the validation logic remains in the body of the command, as it did in the airline framework. Picocli validates them at the parser stage. The rule of thumb for these changes is: The validation logic for commands with a single mandatory input argument is migrated to Picocli annotations by setting arity to `arity="1"` (or `"1..*"`). If the command has more than one mandatory input argument, all arguments are set as "unnecessary," and the validation logic is kept in the command's body as it was before. This avoids refactoring command bodies, simplifies the review, and minimizes the risk of failure, as for some commands, validating the input argument within the command body is not trivial. This comment applies to all similar cases throughout these changes. ########## src/java/org/apache/cassandra/tools/nodetool/RebuildIndex.java: ########## @@ -17,26 +17,38 @@ */ package org.apache.cassandra.tools.nodetool; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.collect.Iterables.toArray; -import io.airlift.airline.Arguments; -import io.airlift.airline.Command; - import java.util.ArrayList; import java.util.List; import org.apache.cassandra.tools.NodeProbe; -import org.apache.cassandra.tools.NodeTool.NodeToolCmd; +import org.apache.cassandra.tools.nodetool.layout.CassandraUsage; +import picocli.CommandLine.Command; +import picocli.CommandLine.Parameters; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.collect.Iterables.toArray; +import static org.apache.cassandra.tools.nodetool.CommandUtils.concatArgs; @Command(name = "rebuild_index", description = "A full rebuild of native secondary indexes for a given table") -public class RebuildIndex extends NodeToolCmd +public class RebuildIndex extends AbstractCommand { - @Arguments(usage = "<keyspace> <table> <indexName...>", description = "The keyspace and table name followed by a list of index names") - List<String> args = new ArrayList<>(); + @CassandraUsage(usage = "<keyspace> <table> <indexName...>", description = "The keyspace and table name followed by a list of index names") + private List<String> args = new ArrayList<>(); + + @Parameters(index = "0", description = "The keyspace name", arity = "0..1") Review Comment: https://github.com/apache/cassandra/pull/2497#discussion_r2204598272 -- 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: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org