diff --git a/src/main/java/com/hafthor/Command.java b/src/main/java/com/hafthor/Command.java index bc1c2ed..61cd779 100644 --- a/src/main/java/com/hafthor/Command.java +++ b/src/main/java/com/hafthor/Command.java @@ -6,7 +6,8 @@ import java.util.List; public class Command { - String errorMessage, inputFile, outputFile; + final String inputFile, outputFile; + String errorMessage; boolean isGzip; List fields; @@ -40,7 +41,7 @@ private String parseOptions(final String[] args) { if ("-f".equals(arg)) { if (next == null || next.isEmpty()) return "missing field definitions"; - fields = Arrays.stream(next.split(",")).toList(); + fields = Arrays.stream(next.split(",")).map(f -> f.trim()).toList(); i++; } else if ("-g".equals(arg)) isGzip = true; diff --git a/src/main/java/com/hafthor/HelpCommand.java b/src/main/java/com/hafthor/HelpCommand.java index a108b8a..532d028 100644 --- a/src/main/java/com/hafthor/HelpCommand.java +++ b/src/main/java/com/hafthor/HelpCommand.java @@ -7,17 +7,17 @@ protected HelpCommand() { @Override public int execute() { - System.out.println("zsvutil syntax:"); - System.out.println(" zsvutil import/export [options] inputfile outputfile"); - System.out.println("options:"); - System.out.println(" -g - export: gzip the output json file / import: gunzip the input json file"); - System.out.println(" -f [string] - fields, default is from contents of input file"); - System.out.println("example: # converts customers.json to customers.zsv with default options"); - System.out.println(" zsvutil import customers.json customers.zsv"); - System.out.println("example: # converts customers.zsv to customers.json.gz with gzip"); - System.out.println(" zsvutil export -g customers.zip customers.tsv.gz"); - System.out.println("Note that, at present, zsvutil requires enough memory to hold the entire uncompressed input file in memory."); - System.out.println("Also note that this utility only supports the base specification of zsv and does not support the extended features."); + System.out.println("zsvutil syntax:\n" + + " zsvutil import/export [options] inputfile outputfile\n" + + "options:\n" + + " -g - export: gzip the output json file / import: gunzip the input json file\n" + + " -f [string] - fields, default is from contents of input file\n" + + "example: # converts customers.json to customers.zsv with default options\n" + + " zsvutil import customers.json customers.zsv\n" + + "example: # converts customers.zsv to customers.json.gz with gzip\n" + + " zsvutil export -g customers.zip customers.tsv.gz\n" + + "Note that, at present, zsvutil requires enough memory to hold the entire uncompressed input file in memory.\n" + + "Also note that this utility only supports the base specification of zsv and does not support the extended features.\n"); return 0; } } \ No newline at end of file