lmccay commented on a change in pull request #296: KNOX-2240 - KnoxShell Custom 
Command for WEBHDFS Use
URL: https://github.com/apache/knox/pull/296#discussion_r396625035
 
 

 ##########
 File path: 
gateway-shell/src/main/java/org/apache/knox/gateway/shell/commands/CSVCommand.java
 ##########
 @@ -49,10 +49,24 @@ public Object execute(List<String> args) {
 
     try {
       if (withHeaders) {
-        table = KnoxShellTable.builder().csv().withHeaders().url(url);
+        if (url.startsWith("$")) {
+          // a knoxshell variable is a csv file as a string
+          String csvString = (String) getVariables().get(url.substring(1));
+          table = 
KnoxShellTable.builder().csv().withHeaders().string(csvString);
+        }
+        else {
+          table = KnoxShellTable.builder().csv().withHeaders().url(url);
+        }
       }
       else {
-        table = KnoxShellTable.builder().csv().url(url);
+        if (url.startsWith("$")) {
+          // a knoxshell variable is a csv file as a string
+          String csvString = (String) getVariables().get(url.substring(1));
+          table = KnoxShellTable.builder().csv().string(csvString);
+        }
+        else {
+          table = KnoxShellTable.builder().csv().url(url);
+        }
 
 Review comment:
   I don't want details of the groovysh leaking into the generic CSV builder 
code. The custom commands provide an abstraction of that layer and isolates it 
from the lower level classes.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to