From 421ec5f3bc6c3e07e8531831a245dc3d85b72d32 Mon Sep 17 00:00:00 2001 From: Robert-96 Date: Sun, 27 Feb 2022 13:58:22 +0200 Subject: [PATCH] Refactor graphwalker-cli --- graphwalker-cli/README.md | 18 +-- .../main/java/org/graphwalker/cli/CLI.java | 128 ++++++------------ .../java/org/graphwalker/cli/Options.java | 10 +- .../org/graphwalker/cli/commands/Check.java | 19 +-- .../org/graphwalker/cli/commands/Convert.java | 17 +-- .../org/graphwalker/cli/commands/Methods.java | 14 +- .../org/graphwalker/cli/commands/Offline.java | 23 ++-- .../org/graphwalker/cli/commands/Online.java | 23 ++-- .../cli/commands/Requirements.java | 14 +- .../org/graphwalker/cli/commands/Source.java | 15 +- .../org/graphwalker/cli/PrintHelpTest.java | 6 +- 11 files changed, 132 insertions(+), 155 deletions(-) diff --git a/graphwalker-cli/README.md b/graphwalker-cli/README.md index c1d43ed4a..d7fd351df 100644 --- a/graphwalker-cli/README.md +++ b/graphwalker-cli/README.md @@ -1,19 +1,21 @@ -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.graphwalker/graphwalker-cli/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.graphwalker/graphwalker-cli) +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.graphwalker/graphwalker-cli/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.graphwalker/graphwalker-cli) GraphWalker CLI -=================== +=============== -====== -Documentation at http://graphwalker.org/docs/command_line_syntax +Documentation at https://github.com/GraphWalker/graphwalker-project/wiki/Command-Line-Tool + +## How to build the standalone jar of graphwalker-cli -### How to build the standalone jar of graphwalker-cli ```bash git clone https://github.com/GraphWalker/graphwalker-project.git cd graphwalker-project mvn package -pl graphwalker-cli -am ``` -The jar is in: +The jar is in: `graphwalker-cli/target/graphwalker-cli-.jar`. + +Run it like: + ```bash -graphwalker-cli/target/graphwalker-cli-3.2.1.jar +java -jar graphwalker-cli/target/graphwalker-cli-.jar ``` - diff --git a/graphwalker-cli/src/main/java/org/graphwalker/cli/CLI.java b/graphwalker-cli/src/main/java/org/graphwalker/cli/CLI.java index 06df9ce9b..edd1b8edc 100644 --- a/graphwalker-cli/src/main/java/org/graphwalker/cli/CLI.java +++ b/graphwalker-cli/src/main/java/org/graphwalker/cli/CLI.java @@ -12,10 +12,10 @@ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -116,106 +116,66 @@ public static void main(String[] args) { private void run(String[] args) { Options options = new Options(); JCommander jc = new JCommander(options); - jc.setProgramName("java -jar graphwalker.jar"); - try { - jc.parseWithoutValidation(args); - } catch (Exception e) { - // ignore - } + jc.setProgramName("graphwalker"); - try { - setLogLevel(options); + offline = new Offline(); + jc.addCommand("offline", offline); - if (options.help) { - options = new Options(); - jc = new JCommander(options); - offline = new Offline(); - jc.addCommand("offline", offline); + online = new Online(); + jc.addCommand("online", online); - online = new Online(); - jc.addCommand("online", online); + methods = new Methods(); + jc.addCommand("methods", methods); - methods = new Methods(); - jc.addCommand("methods", methods); + requirements = new Requirements(); + jc.addCommand("requirements", requirements); - requirements = new Requirements(); - jc.addCommand("requirements", requirements); + convert = new Convert(); + jc.addCommand("convert", convert); - convert = new Convert(); - jc.addCommand("convert", convert); + source = new Source(); + jc.addCommand("source", source); - source = new Source(); - jc.addCommand("source", source); + check = new Check(); + jc.addCommand("check", check); - check = new Check(); - jc.addCommand("check", check); + try { + jc.parse(args); + setLogLevel(options); - jc.parse(args); + if (options.help) { jc.usage(); return; } else if (options.version) { System.out.println(printVersionInformation()); return; + } else if (jc.getParsedCommand() == null) { + throw new MissingCommandException("Missing a command. Add '--help'"); } - // Need to instantiate options again to avoid - // ParameterException "Can only specify option --debug once." - options = new Options(); - jc = new JCommander(options); - offline = new Offline(); - jc.addCommand("offline", offline); - - online = new Online(); - jc.addCommand("online", online); - - methods = new Methods(); - jc.addCommand("methods", methods); - - requirements = new Requirements(); - jc.addCommand("requirements", requirements); - - convert = new Convert(); - jc.addCommand("convert", convert); - - source = new Source(); - jc.addCommand("source", source); - - check = new Check(); - jc.addCommand("check", check); - - jc.parse(args); - // Parse for commands - if (jc.getParsedCommand() != null) { - if (jc.getParsedCommand().equalsIgnoreCase("offline")) { - command = Command.OFFLINE; - runCommandOffline(); - } else if (jc.getParsedCommand().equalsIgnoreCase("online")) { - command = Command.ONLINE; - runCommandOnline(); - } else if (jc.getParsedCommand().equalsIgnoreCase("methods")) { - command = Command.METHODS; - runCommandMethods(); - } else if (jc.getParsedCommand().equalsIgnoreCase("requirements")) { - command = Command.REQUIREMENTS; - runCommandRequirements(); - } else if (jc.getParsedCommand().equalsIgnoreCase("convert")) { - command = Command.CONVERT; - runCommandConvert(); - } else if (jc.getParsedCommand().equalsIgnoreCase("source")) { - command = Command.SOURCE; - runCommandSource(); - } else if (jc.getParsedCommand().equalsIgnoreCase("check")) { - command = Command.SOURCE; - runCommandCheck(); - } - } - - // No commands or options were found - else { - throw new MissingCommandException("Missing a command. Add '--help'"); + if (jc.getParsedCommand().equalsIgnoreCase("offline")) { + command = Command.OFFLINE; + runCommandOffline(); + } else if (jc.getParsedCommand().equalsIgnoreCase("online")) { + command = Command.ONLINE; + runCommandOnline(); + } else if (jc.getParsedCommand().equalsIgnoreCase("methods")) { + command = Command.METHODS; + runCommandMethods(); + } else if (jc.getParsedCommand().equalsIgnoreCase("requirements")) { + command = Command.REQUIREMENTS; + runCommandRequirements(); + } else if (jc.getParsedCommand().equalsIgnoreCase("convert")) { + command = Command.CONVERT; + runCommandConvert(); + } else if (jc.getParsedCommand().equalsIgnoreCase("source")) { + command = Command.SOURCE; + runCommandSource(); + } else if (jc.getParsedCommand().equalsIgnoreCase("check")) { + command = Command.CHECK; + runCommandCheck(); } - } catch (UnsupportedFileFormat | MissingCommandException e) { System.err.println(e.getMessage() + System.lineSeparator()); } catch (ParameterException e) { diff --git a/graphwalker-cli/src/main/java/org/graphwalker/cli/Options.java b/graphwalker-cli/src/main/java/org/graphwalker/cli/Options.java index 6ff097041..951bfa7ed 100644 --- a/graphwalker-cli/src/main/java/org/graphwalker/cli/Options.java +++ b/graphwalker-cli/src/main/java/org/graphwalker/cli/Options.java @@ -12,10 +12,10 @@ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -30,12 +30,12 @@ public class Options { - @Parameter(names = {"--help", "-h"}, description = "Prints help text") + @Parameter(names = {"--help", "-h"}, help = true, description = "Show this message and exit.") public boolean help = false; - @Parameter(names = {"--version", "-v"}, description = "Prints the version of graphwalker") + @Parameter(names = {"--version", "-v"}, help = true, description = "Show the graphwalker version and exit.") public boolean version = false; - @Parameter(names = {"--debug", "-d"}, description = "Sets the log level: OFF, ERROR, WARN, INFO, DEBUG, TRACE, ALL. Default is OFF") + @Parameter(names = {"--debug", "-d"}, description = "Sets the log level. Valid log levels are: OFF, ERROR, WARN, INFO, DEBUG, TRACE, ALL.") public String debug = "OFF"; } diff --git a/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Check.java b/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Check.java index 3c933c377..6d5c2b508 100644 --- a/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Check.java +++ b/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Check.java @@ -12,10 +12,10 @@ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -31,15 +31,18 @@ import java.util.ArrayList; import java.util.List; -@Parameters(commandDescription = "Check and analyze model(s) for issues. See http://graphwalker.org/docs/command_line_syntax") +@Parameters(commandDescription = "Check and analyze model(s) for issues.") public class Check { - @Parameter(names = {"--model", "-m"}, required = true, arity = 2, - description = "Model followed by generator with stop condition. " + - "The format is GENERATOR(STOP_CONDITION) See http://graphwalker.org/docs/path_generators_and_stop_conditions") + @Parameter(names = {"--model", "-m"}, required = false, arity = 2, + description = "The model(s), as a GRAPHML or JSON file followed by generator with stop condition. " + + "The format is GENERATOR(STOP_CONDITION) (e.g \"random(never)\", \"weighted_random(length(24))\"). " + + "This option can occur multiple times.") public List model = new ArrayList<>(); - @Parameter(names = {"--blocked", - "-b"}, arity = 1, description = "This option enables or disables the BLOCKED feature. When \"-b true\" GraphWalker will filter out elements in models with the keyword BLOCKED. When \"-b false\" GraphWalker will not filter out any elements in models with the keyword BLOCKED.") + @Parameter(names = {"--blocked", "-b"}, arity = 1, + description = "This option enables or disables the BLOCKED feature. " + + "When \"-b true\" GraphWalker will filter out any elements with the keyword BLOCKED. " + + "When \"-b false\" GraphWalker will not filter out elements with the keyword BLOCKED.") public boolean blocked = true; } diff --git a/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Convert.java b/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Convert.java index eb7e235a9..73c2ead77 100644 --- a/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Convert.java +++ b/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Convert.java @@ -12,10 +12,10 @@ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -30,19 +30,20 @@ import com.beust.jcommander.Parameters; import org.graphwalker.io.factory.ContextFactoryScanner; -@Parameters(commandDescription = "Convert a graph in file format, to some other format. See http://graphwalker.org/docs/command_line_syntax") +@Parameters(commandDescription = "Convert a graph from one format, to some other format.") public class Convert { @Parameter(names = {"--input", "-i"}, required = true, arity = 1, - description = "This command requires an input file." + - "See http://graphwalker.org/docs/command_line_syntax") + description = "The input model file.") public String input = ""; @Parameter(names = {"--format", "-f"}, required = false, arity = 1, - description = "Which format to convert into. Valid key words are: JSON [default], GRAPHML, DOT or JAVA") + description = "Which format to convert into. Valid key words are: JSON [default], GRAPHML, DOT or JAVA.") public String format = ContextFactoryScanner.JSON; - @Parameter(names = {"--blocked", - "-b"}, arity = 1, description = "This option enables or disables the BLOCKED feature. When \"-b true\" GraphWalker will filter out elements in models with the keyword BLOCKED. When \"-b false\" GraphWalker will not filter out any elements in models with the keyword BLOCKED.") + @Parameter(names = {"--blocked", "-b"}, arity = 1, + description = "This option enables or disables the BLOCKED feature. " + + "When \"-b true\" GraphWalker will filter out any elements with the keyword BLOCKED. " + + "When \"-b false\" GraphWalker will not filter out elements with the keyword BLOCKED.") public boolean blocked = true; } diff --git a/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Methods.java b/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Methods.java index 573afcc92..a05583829 100644 --- a/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Methods.java +++ b/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Methods.java @@ -12,10 +12,10 @@ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -31,14 +31,16 @@ import java.util.ArrayList; import java.util.List; -@Parameters(commandDescription = "Generates a list of unique names of vertices and edges in the model. See http://graphwalker.org/docs/command_line_syntax") +@Parameters(commandDescription = "Generates a list of unique names of vertices and edges in the model.") public class Methods { @Parameter(names = {"--model", "-m"}, required = true, - description = "The model(s)") + description = "The model(s), as a GRAPHML or JSON file. This option can occur multiple times.") public List model = new ArrayList<>(); - @Parameter(names = {"--blocked", - "-b"}, arity = 1, description = "This option enables or disables the BLOCKED feature. When \"-b true\" GraphWalker will filter out elements in models with the keyword BLOCKED. When \"-b false\" GraphWalker will not filter out any elements in models with the keyword BLOCKED.") + @Parameter(names = {"--blocked", "-b"}, arity = 1, + description = "This option enables or disables the BLOCKED feature. " + + "When \"-b true\" GraphWalker will filter out any elements with the keyword BLOCKED. " + + "When \"-b false\" GraphWalker will not filter out elements with the keyword BLOCKED.") public boolean blocked = true; } diff --git a/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Offline.java b/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Offline.java index e6f0d1374..5b168c409 100644 --- a/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Offline.java +++ b/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Offline.java @@ -12,10 +12,10 @@ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -31,11 +31,11 @@ import java.util.ArrayList; import java.util.List; -@Parameters(commandDescription = "Generate a test sequence offline. The sequence is printed to the standard output. See http://graphwalker.org/docs/command_line_syntax") +@Parameters(commandDescription = "Offline means generating a test sequence that can later be run automatically. The sequence is printed to the standard output.") public class Offline { @Parameter(names = {"--verbose", "-o"}, required = false, - description = "Will print more details to stdout") + description = "Will print more details to stdout.") public boolean verbose = false; @Parameter(names = {"--unvisited", "-u"}, required = false, @@ -43,23 +43,26 @@ public class Offline { public boolean unvisited = false; @Parameter(names = {"--model", "-m"}, required = false, arity = 2, - description = "The model, as a graphml file followed by generator with stop condition. " + - "The format is GENERATOR(STOP_CONDITION) See http://graphwalker.org/docs/path_generators_and_stop_conditions") + description = "The model(s), as a GRAPHML or JSON file followed by generator with stop condition. " + + "The format is GENERATOR(STOP_CONDITION) (e.g \"random(never)\", \"weighted_random(length(24))\"). " + + "This option can occur multiple times.") public List model = new ArrayList<>(); @Parameter(names = {"--gw3", "-g"}, required = false, arity = 1, - description = "The model, as a single gw3 file") + description = "The model, as a single gw3 file.") public String gw3 = ""; @Parameter(names = {"--start-element", "-e"}, required = false, description = "Sets the starting element in the [first] model.") public String startElement = ""; - @Parameter(names = {"--blocked", - "-b"}, arity = 1, description = "This option enables or disables the BLOCKED feature. When \"-b true\" GraphWalker will filter out elements in models with the keyword BLOCKED. When \"-b false\" GraphWalker will not filter out any elements in models with the keyword BLOCKED.") + @Parameter(names = {"--blocked", "-b"}, arity = 1, + description = "This option enables or disables the BLOCKED feature. " + + "When \"-b true\" GraphWalker will filter out any elements with the keyword BLOCKED. " + + "When \"-b false\" GraphWalker will not filter out elements with the keyword BLOCKED.") public boolean blocked = true; @Parameter(names = {"--seed", "-d"}, required = false, - description = "Seed the random generator using the provided number.") + description = "Seed the random generator using the provided number. Using a seeded number, will generate the same path every time.") public long seed = 0; } diff --git a/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Online.java b/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Online.java index c9220a62f..629ca8cec 100644 --- a/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Online.java +++ b/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Online.java @@ -12,10 +12,10 @@ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -31,14 +31,14 @@ import java.util.ArrayList; import java.util.List; -@Parameters(commandDescription = "Starts GraphWalker as a WebSocket server. See http://graphwalker.org/docs/websocket_api") +@Parameters(commandDescription = "Starts GraphWalker server either as a WebSocket (default) or a HTTP REST server.") public class Online { public static final String SERVICE_RESTFUL = "RESTFUL"; public static final String SERVICE_WEBSOCKET = "WEBSOCKET"; @Parameter(names = {"--verbose", "-o"}, required = false, - description = "Will print more details") + description = "Will print more details to stdout.") public boolean verbose = false; @Parameter(names = {"--unvisited", "-u"}, required = false, @@ -46,22 +46,25 @@ public class Online { public boolean unvisited = false; @Parameter(names = {"--model", "-m"}, required = false, arity = 2, - description = "The model, as a graphml file followed by generator with stop condition. " + - "The format is GENERATOR(STOP_CONDITION) See http://graphwalker.org/docs/path_generators_and_stop_conditions") + description = "The model(s), as a GRAPHML or JSON file followed by generator with stop condition. " + + "The format is GENERATOR(STOP_CONDITION) (e.g \"random(never)\", \"weighted_random(length(24))\"). " + + "This option can occur multiple times.") public List model = new ArrayList<>(); @Parameter(names = {"--service", "-s"}, required = false, arity = 1, - description = "Selects which kind of service to start. Either WEBSOCKET [default], or RESTFUL") + description = "Selects which kind of service to start. Either WEBSOCKET [default], or RESTFUL.") public String service = SERVICE_WEBSOCKET; - @Parameter(names = {"--port", "-p"}, description = "Sets the port of the service") + @Parameter(names = {"--port", "-p"}, description = "Sets the port of the service.") public int port = 8887; @Parameter(names = {"--start-element", "-e"}, required = false, description = "Sets the starting element in the [first] model.") public String startElement = ""; - @Parameter(names = {"--blocked", - "-b"}, arity = 1, description = "This option enables or disables the BLOCKED feature. When \"-b true\" GraphWalker will filter out elements in models with the keyword BLOCKED. When \"-b false\" GraphWalker will not filter out any elements in models with the keyword BLOCKED.") + @Parameter(names = {"--blocked", "-b"}, arity = 1, + description = "This option enables or disables the BLOCKED feature. " + + "When \"-b true\" GraphWalker will filter out any elements with the keyword BLOCKED. " + + "When \"-b false\" GraphWalker will not filter out elements with the keyword BLOCKED.") public boolean blocked = true; } diff --git a/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Requirements.java b/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Requirements.java index 32b0907d7..9394dcb83 100644 --- a/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Requirements.java +++ b/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Requirements.java @@ -12,10 +12,10 @@ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -31,14 +31,16 @@ import java.util.ArrayList; import java.util.List; -@Parameters(commandDescription = "Generates a list of unique names of the requirements found in the model. See http://graphwalker.org/docs/command_line_syntax") +@Parameters(commandDescription = "Generates a list of unique names of the requirements found in the model.") public class Requirements { @Parameter(names = {"--model", "-m"}, required = true, - description = "The model(s)") + description = "The model(s), as a GRAPHML or JSON file. This option can occur multiple times.") public List model = new ArrayList<>(); - @Parameter(names = {"--blocked", - "-b"}, arity = 1, description = "This option enables or disables the BLOCKED feature. When \"-b true\" GraphWalker will filter out elements in models with the keyword BLOCKED. When \"-b false\" GraphWalker will not filter out any elements in models with the keyword BLOCKED.") + @Parameter(names = {"--blocked", "-b"}, arity = 1, + description = "This option enables or disables the BLOCKED feature. " + + "When \"-b true\" GraphWalker will filter out any elements with the keyword BLOCKED. " + + "When \"-b false\" GraphWalker will not filter out elements with the keyword BLOCKED.") public boolean blocked = true; } diff --git a/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Source.java b/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Source.java index 84164f796..f5bf69bcb 100644 --- a/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Source.java +++ b/graphwalker-cli/src/main/java/org/graphwalker/cli/commands/Source.java @@ -12,10 +12,10 @@ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -31,15 +31,16 @@ import java.util.ArrayList; import java.util.List; -@Parameters(commandDescription = "Will generate source code using the provided model and a template. See http://graphwalker.org/docs/command_line_syntax") +@Parameters(commandDescription = "Will generate source code using the provided model and a template.") public class Source { @Parameter(names = {"--input", "-i"}, required = true, arity = 2, - description = "This command requires an input model file, and an input template file. " + - "See http://graphwalker.org/docs/command_line_syntax") + description = "The input model file, and an input template file.") public List input = new ArrayList<>(); - @Parameter(names = {"--blocked", - "-b"}, arity = 1, description = "This option enables or disables the BLOCKED feature. When \"-b true\" GraphWalker will filter out elements in models with the keyword BLOCKED. When \"-b false\" GraphWalker will not filter out any elements in models with the keyword BLOCKED.") + @Parameter(names = {"--blocked", "-b"}, arity = 1, + description = "This option enables or disables the BLOCKED feature. " + + "When \"-b true\" GraphWalker will filter out any elements with the keyword BLOCKED. " + + "When \"-b false\" GraphWalker will not filter out elements with the keyword BLOCKED.") public boolean blocked = true; } diff --git a/graphwalker-cli/src/test/java/org/graphwalker/cli/PrintHelpTest.java b/graphwalker-cli/src/test/java/org/graphwalker/cli/PrintHelpTest.java index 8572c25bf..a1eb3cb3e 100644 --- a/graphwalker-cli/src/test/java/org/graphwalker/cli/PrintHelpTest.java +++ b/graphwalker-cli/src/test/java/org/graphwalker/cli/PrintHelpTest.java @@ -10,10 +10,10 @@ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -41,6 +41,6 @@ public void help() throws IOException { String args[] = {"--help"}; Result result = runCommand(args); Assert.assertThat(result.getError(), is("")); - Assert.assertThat(result.getOutput(), containsString("Usage:
[options] [command] [command options]")); + Assert.assertThat(result.getOutput(), containsString("Usage: graphwalker [options] [command] [command options]")); } }