diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-10-15 11:56:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-15 11:56:04 +0200 |
commit | b3e088d6a4cbbe629a4545f15107da56e1008ff2 (patch) | |
tree | 551a6c61e6c6b0c79951b33c1c7b2c7acf1802a5 /vespaclient-java | |
parent | 9c659b309fcb0bb824bba56da8d3848675d14cd3 (diff) | |
parent | ae2daa90050c1bd218e92b27e568a3de4e6c59a3 (diff) |
Merge pull request #7308 from vespa-engine/bjorncs/vespaget-vespavisit-json
Add --xmloutput to vespa-get + vespa-visit
Diffstat (limited to 'vespaclient-java')
-rw-r--r-- | vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java | 13 | ||||
-rw-r--r-- | vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java | 15 |
2 files changed, 25 insertions, 3 deletions
diff --git a/vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java b/vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java index 51138db8d00..76aaf283a16 100644 --- a/vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java +++ b/vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java @@ -37,6 +37,7 @@ public class CommandLineOptions { public static final String PRIORITY_OPTION = "priority"; public static final String LOADTYPE_OPTION = "loadtype"; public static final String JSONOUTPUT_OPTION = "jsonoutput"; + public static final String XMLOUTPUT_OPTION = "xmloutput"; private final Options options = createOptions(); private final InputStream stdIn; @@ -136,6 +137,11 @@ public class CommandLineOptions { .desc("JSON output") .longOpt(JSONOUTPUT_OPTION).build()); + options.addOption(Option.builder("x") + .hasArg(false) + .desc("XML output (default format)") + .longOpt(XMLOUTPUT_OPTION).build()); + return options; } @@ -165,11 +171,16 @@ public class CommandLineOptions { boolean noRetry = cl.hasOption(NORETRY_OPTION); boolean showDocSize = cl.hasOption(SHOWDOCSIZE_OPTION); boolean jsonOutput = cl.hasOption(JSONOUTPUT_OPTION); + boolean xmlOutput = cl.hasOption(XMLOUTPUT_OPTION); int trace = getTrace(cl); DocumentProtocol.Priority priority = getPriority(cl); double timeout = getTimeout(cl); Iterator<String> documentIds = getDocumentIds(cl); + if (jsonOutput && xmlOutput) { + throw new IllegalArgumentException("Cannot combine both xml and json output"); + } + if (printIdsOnly && headersOnly) { throw new IllegalArgumentException("Print ids and headers only options are mutually exclusive."); } @@ -216,7 +227,7 @@ public class CommandLineOptions { .setTraceLevel(trace) .setPriority(priority) .setTimeout(timeout) - .setJsonOutput(jsonOutput) + .setJsonOutput(!jsonOutput && !xmlOutput ? false : jsonOutput) // TODO Vespa 7 Change default to JSON .build(); } catch (ParseException pe) { throw new IllegalArgumentException(pe.getMessage()); diff --git a/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java b/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java index 16d860a1d98..1df9a1e38cd 100644 --- a/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java +++ b/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java @@ -349,6 +349,13 @@ public class VdsVisit { .hasArg(false) .build()); + options.addOption(Option.builder("x") + .longOpt("xmloutput") + .desc("Output documents as XML (default format)") + .hasArg(false) + .build()); + + options.addOption(Option.builder() .longOpt("bucketspace") .hasArg(true) @@ -573,9 +580,13 @@ public class VdsVisit { throttlePolicy.setMaxPendingCount(((Number)line.getParsedOptionValue("maxpendingsuperbuckets")).intValue()); params.setThrottlePolicy(throttlePolicy); } - if (line.hasOption("jsonoutput")) { - allParams.setJsonOutput(true); + + boolean jsonOutput = line.hasOption("jsonoutput"); + boolean xmlOutput = line.hasOption("xmloutput"); + if (jsonOutput && xmlOutput) { + throw new IllegalArgumentException("Cannot combine both xml and json output"); } + allParams.setJsonOutput(!jsonOutput && !xmlOutput ? false : jsonOutput); // TODO Vespa 7 Change default to JSON allParams.setVisitorParameters(params); return allParams; |