walterddr commented on code in PR #8659:
URL: https://github.com/apache/pinot/pull/8659#discussion_r868278629


##########
pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/FileSystemCommand.java:
##########
@@ -0,0 +1,227 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.tools.admin.command;
+
+import com.google.common.collect.ImmutableMap;
+import java.io.File;
+import java.io.PrintStream;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.pinot.spi.env.PinotConfiguration;
+import org.apache.pinot.spi.filesystem.PinotFS;
+import org.apache.pinot.spi.filesystem.PinotFSFactory;
+import org.apache.pinot.spi.plugin.PluginManager;
+import org.apache.pinot.spi.utils.StringUtil;
+import org.apache.pinot.tools.Command;
+import org.apache.pinot.tools.utils.PinotConfigUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+
+
+@CommandLine.Command(name = "FileSystem")
+public class FileSystemCommand extends AbstractBaseAdminCommand implements 
Command {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(FileSystemCommand.class.getName());
+
+  private static final String[] SUPPORTED_FS_COMMANDS = new String[]{
+      "EXISTS", "IS_DIR", "LAST_MODIFIED", "LENGTH",
+      "LIST_FILE", "LIST_FILE_RECURSIVE",
+      "CP", "COPY_DIR",
+      "COPY_FROM_LOCAL_FILE", "COPY_FROM_LOCAL_DIR", "COPY_TO_LOCAL_FILE",
+      "MV", "DELETE"
+  };
+
+  @CommandLine.Option(names = {"-scheme"}, required = true, description = 
"PinotFS scheme name, e.g. "
+      + "file/s3/adls/gcs/hdfs.")
+  private String _scheme;
+
+  @CommandLine.Option(names = {"-config", "-configFile"}, description =
+      "PinotFS Config file.")
+  private String _configFile;
+
+  @CommandLine.Option(names = {"-command"}, required = true, arity = "1..*", 
description = "File system command, e.g."
+      + " EXISTS, IS_DIR, LAST_MODIFIED, LENGTH, LIST_FILE, 
LIST_FILE_RECURSIVE, CP, COPY_DIR, COPY_FROM_LOCAL_FILE, "
+      + "COPY_FROM_LOCAL_DIR, COPY_TO_LOCAL_FILE, MV, DELETE")
+  private String[] _command;
+
+  @CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, usageHelp = 
true, description = "Print this message.")
+  private boolean _help = false;
+
+  public FileSystemCommand setScheme(String scheme) {
+    _scheme = scheme;
+    return this;
+  }
+
+  public FileSystemCommand setConfigFile(String configFile) {
+    _configFile = configFile;
+    return this;
+  }
+
+  public FileSystemCommand setCommand(String[] command) {
+    _command = command;
+    return this;
+  }
+
+  public FileSystemCommand setHelp(boolean help) {
+    _help = help;
+    return this;
+  }
+
+  public String getScheme() {
+    return _scheme;
+  }
+
+  public String getConfigFile() {
+    return _configFile;
+  }
+
+  public String[] getCommand() {
+    return _command;
+  }
+
+  @Override
+  public boolean getHelp() {
+    return _help;
+  }
+
+  @Override
+  public String getName() {
+    return "FileSystem";
+  }
+
+  @Override
+  public String toString() {
+    return ("FileSystem --scheme " + _scheme + " -configFileName " + 
_configFile + " -command " + Arrays.toString(
+        _command));

Review Comment:
   you can use https://picocli.info/#_subcommand_examples if this helps. 
   `pinot-admin.sh  FileSystem [-scheme s3] [-config /tmp/fs.conf] ls -al 
s3://<my-bucket>/`
   
   PRO: no need for -command
   CON: you need to implement some kind of subcommand base class to move your 
switch case branch into
   



##########
pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/FileSystemCommand.java:
##########
@@ -0,0 +1,227 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.tools.admin.command;
+
+import com.google.common.collect.ImmutableMap;
+import java.io.File;
+import java.io.PrintStream;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.pinot.spi.env.PinotConfiguration;
+import org.apache.pinot.spi.filesystem.PinotFS;
+import org.apache.pinot.spi.filesystem.PinotFSFactory;
+import org.apache.pinot.spi.plugin.PluginManager;
+import org.apache.pinot.spi.utils.StringUtil;
+import org.apache.pinot.tools.Command;
+import org.apache.pinot.tools.utils.PinotConfigUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+
+
+@CommandLine.Command(name = "FileSystem")
+public class FileSystemCommand extends AbstractBaseAdminCommand implements 
Command {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(FileSystemCommand.class.getName());
+
+  private static final String[] SUPPORTED_FS_COMMANDS = new String[]{
+      "EXISTS", "IS_DIR", "LAST_MODIFIED", "LENGTH",
+      "LIST_FILE", "LIST_FILE_RECURSIVE",
+      "CP", "COPY_DIR",
+      "COPY_FROM_LOCAL_FILE", "COPY_FROM_LOCAL_DIR", "COPY_TO_LOCAL_FILE",
+      "MV", "DELETE"
+  };
+
+  @CommandLine.Option(names = {"-scheme"}, required = true, description = 
"PinotFS scheme name, e.g. "
+      + "file/s3/adls/gcs/hdfs.")
+  private String _scheme;
+
+  @CommandLine.Option(names = {"-config", "-configFile"}, description =
+      "PinotFS Config file.")
+  private String _configFile;
+
+  @CommandLine.Option(names = {"-command"}, required = true, arity = "1..*", 
description = "File system command, e.g."
+      + " EXISTS, IS_DIR, LAST_MODIFIED, LENGTH, LIST_FILE, 
LIST_FILE_RECURSIVE, CP, COPY_DIR, COPY_FROM_LOCAL_FILE, "
+      + "COPY_FROM_LOCAL_DIR, COPY_TO_LOCAL_FILE, MV, DELETE")
+  private String[] _command;
+
+  @CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, usageHelp = 
true, description = "Print this message.")
+  private boolean _help = false;
+
+  public FileSystemCommand setScheme(String scheme) {
+    _scheme = scheme;
+    return this;
+  }
+
+  public FileSystemCommand setConfigFile(String configFile) {
+    _configFile = configFile;
+    return this;
+  }
+
+  public FileSystemCommand setCommand(String[] command) {
+    _command = command;
+    return this;
+  }
+
+  public FileSystemCommand setHelp(boolean help) {
+    _help = help;
+    return this;
+  }
+
+  public String getScheme() {
+    return _scheme;
+  }
+
+  public String getConfigFile() {
+    return _configFile;
+  }
+
+  public String[] getCommand() {
+    return _command;
+  }
+
+  @Override
+  public boolean getHelp() {
+    return _help;
+  }
+
+  @Override
+  public String getName() {
+    return "FileSystem";
+  }
+
+  @Override
+  public String toString() {
+    return ("FileSystem --scheme " + _scheme + " -configFileName " + 
_configFile + " -command " + Arrays.toString(
+        _command));

Review Comment:
   you can use https://picocli.info/#_subcommand_examples if this helps. 
   `pinot-admin.sh  FileSystem [-scheme s3] [-config /tmp/fs.conf] ls -al 
s3://<my-bucket>/`
   
   PRO: no need for -command
   CON: you need to implement some kind of subcommand base class to move your 
switch case clause into
   



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to