Java CommandLine Interface implementation
$begingroup$
I wrote got a lot of mini apps. Each app has it's own InputHandler for Input from the keyboard. It's time to make a lib for that purpose - a CommandLineInterface
.
Can you review my code on
- Design
- OOP
- Clean Code
- Naming (my bad englisch leads to bad naming)
Interface CommandLineInterpreter
any class that implements this interface can be use the CommandLineInterface
. M
is the application, which implements the CommandLineInterpreter
public interface CommandLineInterpreter<M> {
Set<Command<M>> getCommands();
Response executeCommand(String identifier, List<String> parameter);
}
Class Command
the Command
is responible to map in command typed via CLI into an action (method-call) on your app. To execute the command the Class is generic on M
(which is your app) so you can call these app-specific methods.
public abstract class Command<M> {
private final String identifier;
public Command(String identifier) {
this.identifier = identifier;
}
public abstract Response execute(M invoked, List<String> parameter);
public String getIdentifier() {
return identifier;
}
public boolean isIdentifier(String ident) {
return identifier.equals(ident);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Command command = (Command) o;
return Objects.equals(identifier, command.identifier);
}
@Override
public int hashCode() {
return Objects.hash(identifier);
}
}
Class Response
provides information if the execution of an command was successful or not.
public class Response {
private final String message;
private final String details;
private final Type type;
private Response(Type type, String message, String details) {
this.type = type;
this.message = message;
this.details = details;
}
public static Response fail(String message) {
return fail(message, "");
}
public static Response fail(String message, String details) {
return response(Type.FAILURE, message, details);
}
private static Response response(Type type, String message, String details) {
return new Response(type, message, details);
}
public static Response success() {
return success("ok", "");
}
public static Response success(String message) {
return success(message, "");
}
public static Response success(String message, String details) {
return response(Type.SUCCESS, message, details);
}
public boolean failed() {
return type == Type.FAILURE;
}
@Override
public String toString() {
return type.toString() + ":" + message + (details.isEmpty() ? "" : "
Details: " + details);
}
private enum Type {SUCCESS, FAILURE}
Class CommandLineInterface
this class handles the user input fromm command line. it is itself an CommandLineInterpreter
and offers two basic commands: help
and exit
.
public class CommandLineInterface implements CommandLineInterpreter<CommandLineInterface> {
private static final String COMMAND_SEPARATOR = " ";
private final CommandLineInterpreter cli;
private final InputStream input;
private final PrintStream output;
private boolean isRunning = true;
public CommandLineInterface(CommandLineInterpreter<?> cli, InputStream input, PrintStream output) {
if (cli == null || hasPredefinedCommands(cli.getCommands())) {
throw new RuntimeException("CommandLineInterpreter interface of " + cli + " is not properly implemented");
}
this.cli = cli;
this.input = input;
this.output = output;
}
private boolean hasPredefinedCommands(Set<? extends Command<?>> commands) {
return !Collections.disjoint(commands, getCommands());
}
public void start() {
Scanner scanner = new Scanner(input);
showHelp();
while (isRunning) {
output.print("$>");
String command = scanner.nextLine();
List<String> line = Arrays.asList(command.split(COMMAND_SEPARATOR));
String identifier = line.get(0);
List<String> parameters = line.subList(1, line.size());
if (isExecutableCommand(identifier)) {
Response response = executeCommand(identifier, parameters);
if (response.failed()) {
showResponse(response);
}
} else {
showHelp();
}
}
}
private boolean isExecutableCommand(String identifier) {
for (Command cmd : getAllCommands()) {
if (cmd.isIdentifier(identifier)) {
return true;
}
}
return false;
}
private void showHelp() {
Set<Command<?>> commands = getAllCommands();
output.println("help - these commands are available:");
commands.forEach(c -> output.printf(" - %sn", c.getIdentifier()));
}
private void showResponse(Response response) {
output.println(response);
}
@Override
public Set<Command<CommandLineInterface>> getCommands() {
Set<Command<CommandLineInterface>> cliCommands = new HashSet<>();
cliCommands.add(new Command<CommandLineInterface>("exit") {
@Override
public Response execute(CommandLineInterface commandLineInterface, List<String> parameter) {
isRunning = false;
return Response.success();
}
});
cliCommands.add(new Command<CommandLineInterface>("help") {
@Override
public Response execute(CommandLineInterface commandLineInterface, List<String> parameter) {
showHelp();
return Response.success();
}
});
return cliCommands;
}
private Set<Command<?>> getAllCommands() {
Set<Command<?>> commands = mapCommands(cli.getCommands());
commands.addAll(getCommands());
return commands;
}
private Set<Command<?>> mapCommands(Set commands) {
Set<Command<?>> mappedCommands = new HashSet<>();
for (Object o : commands) mapCommand(o).ifPresent(mappedCommands::add);
return mappedCommands;
}
private Optional<Command<?>> mapCommand(Object o) {
return (o instanceof Command<?>) ? Optional.of((Command<?>) o) : Optional.empty();
}
@Override
public Response executeCommand(String identifier, List<String> parameter) {
Optional<Command<CommandLineInterface>> cmd = getCommands().stream().filter(command -> command.isIdentifier(identifier)).findAny();
if (cmd.isPresent()) {
return cmd.get().execute(this, parameter);
} else {
return cli.executeCommand(identifier, parameter);
}
}
}
Example
if you have implementet the interfaces properly you should have easy to use CLI support for your apps:
public static void main(String args) {
ExampleApplication app = new ExampleApplication();//implements CommandLineInterpreter
CommandLineInterface commandLineInterface = new CommandLineInterface(app, System.in, System.out);
commandLineInterface.start();
}
Output
this is an example output from an example app that does not much...
help - these commands are available:
- exampleCommand
- help
- exit
$>help
help - these commands are available:
- exampleCommand
- help
- exit
$>exampleCommand p1 p2 p3
i could do some actual work now if i were not a mere example, parameter [p1, p2, p3]
$>exit
Process finished with exit code 0
java object-oriented
$endgroup$
add a comment |
$begingroup$
I wrote got a lot of mini apps. Each app has it's own InputHandler for Input from the keyboard. It's time to make a lib for that purpose - a CommandLineInterface
.
Can you review my code on
- Design
- OOP
- Clean Code
- Naming (my bad englisch leads to bad naming)
Interface CommandLineInterpreter
any class that implements this interface can be use the CommandLineInterface
. M
is the application, which implements the CommandLineInterpreter
public interface CommandLineInterpreter<M> {
Set<Command<M>> getCommands();
Response executeCommand(String identifier, List<String> parameter);
}
Class Command
the Command
is responible to map in command typed via CLI into an action (method-call) on your app. To execute the command the Class is generic on M
(which is your app) so you can call these app-specific methods.
public abstract class Command<M> {
private final String identifier;
public Command(String identifier) {
this.identifier = identifier;
}
public abstract Response execute(M invoked, List<String> parameter);
public String getIdentifier() {
return identifier;
}
public boolean isIdentifier(String ident) {
return identifier.equals(ident);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Command command = (Command) o;
return Objects.equals(identifier, command.identifier);
}
@Override
public int hashCode() {
return Objects.hash(identifier);
}
}
Class Response
provides information if the execution of an command was successful or not.
public class Response {
private final String message;
private final String details;
private final Type type;
private Response(Type type, String message, String details) {
this.type = type;
this.message = message;
this.details = details;
}
public static Response fail(String message) {
return fail(message, "");
}
public static Response fail(String message, String details) {
return response(Type.FAILURE, message, details);
}
private static Response response(Type type, String message, String details) {
return new Response(type, message, details);
}
public static Response success() {
return success("ok", "");
}
public static Response success(String message) {
return success(message, "");
}
public static Response success(String message, String details) {
return response(Type.SUCCESS, message, details);
}
public boolean failed() {
return type == Type.FAILURE;
}
@Override
public String toString() {
return type.toString() + ":" + message + (details.isEmpty() ? "" : "
Details: " + details);
}
private enum Type {SUCCESS, FAILURE}
Class CommandLineInterface
this class handles the user input fromm command line. it is itself an CommandLineInterpreter
and offers two basic commands: help
and exit
.
public class CommandLineInterface implements CommandLineInterpreter<CommandLineInterface> {
private static final String COMMAND_SEPARATOR = " ";
private final CommandLineInterpreter cli;
private final InputStream input;
private final PrintStream output;
private boolean isRunning = true;
public CommandLineInterface(CommandLineInterpreter<?> cli, InputStream input, PrintStream output) {
if (cli == null || hasPredefinedCommands(cli.getCommands())) {
throw new RuntimeException("CommandLineInterpreter interface of " + cli + " is not properly implemented");
}
this.cli = cli;
this.input = input;
this.output = output;
}
private boolean hasPredefinedCommands(Set<? extends Command<?>> commands) {
return !Collections.disjoint(commands, getCommands());
}
public void start() {
Scanner scanner = new Scanner(input);
showHelp();
while (isRunning) {
output.print("$>");
String command = scanner.nextLine();
List<String> line = Arrays.asList(command.split(COMMAND_SEPARATOR));
String identifier = line.get(0);
List<String> parameters = line.subList(1, line.size());
if (isExecutableCommand(identifier)) {
Response response = executeCommand(identifier, parameters);
if (response.failed()) {
showResponse(response);
}
} else {
showHelp();
}
}
}
private boolean isExecutableCommand(String identifier) {
for (Command cmd : getAllCommands()) {
if (cmd.isIdentifier(identifier)) {
return true;
}
}
return false;
}
private void showHelp() {
Set<Command<?>> commands = getAllCommands();
output.println("help - these commands are available:");
commands.forEach(c -> output.printf(" - %sn", c.getIdentifier()));
}
private void showResponse(Response response) {
output.println(response);
}
@Override
public Set<Command<CommandLineInterface>> getCommands() {
Set<Command<CommandLineInterface>> cliCommands = new HashSet<>();
cliCommands.add(new Command<CommandLineInterface>("exit") {
@Override
public Response execute(CommandLineInterface commandLineInterface, List<String> parameter) {
isRunning = false;
return Response.success();
}
});
cliCommands.add(new Command<CommandLineInterface>("help") {
@Override
public Response execute(CommandLineInterface commandLineInterface, List<String> parameter) {
showHelp();
return Response.success();
}
});
return cliCommands;
}
private Set<Command<?>> getAllCommands() {
Set<Command<?>> commands = mapCommands(cli.getCommands());
commands.addAll(getCommands());
return commands;
}
private Set<Command<?>> mapCommands(Set commands) {
Set<Command<?>> mappedCommands = new HashSet<>();
for (Object o : commands) mapCommand(o).ifPresent(mappedCommands::add);
return mappedCommands;
}
private Optional<Command<?>> mapCommand(Object o) {
return (o instanceof Command<?>) ? Optional.of((Command<?>) o) : Optional.empty();
}
@Override
public Response executeCommand(String identifier, List<String> parameter) {
Optional<Command<CommandLineInterface>> cmd = getCommands().stream().filter(command -> command.isIdentifier(identifier)).findAny();
if (cmd.isPresent()) {
return cmd.get().execute(this, parameter);
} else {
return cli.executeCommand(identifier, parameter);
}
}
}
Example
if you have implementet the interfaces properly you should have easy to use CLI support for your apps:
public static void main(String args) {
ExampleApplication app = new ExampleApplication();//implements CommandLineInterpreter
CommandLineInterface commandLineInterface = new CommandLineInterface(app, System.in, System.out);
commandLineInterface.start();
}
Output
this is an example output from an example app that does not much...
help - these commands are available:
- exampleCommand
- help
- exit
$>help
help - these commands are available:
- exampleCommand
- help
- exit
$>exampleCommand p1 p2 p3
i could do some actual work now if i were not a mere example, parameter [p1, p2, p3]
$>exit
Process finished with exit code 0
java object-oriented
$endgroup$
add a comment |
$begingroup$
I wrote got a lot of mini apps. Each app has it's own InputHandler for Input from the keyboard. It's time to make a lib for that purpose - a CommandLineInterface
.
Can you review my code on
- Design
- OOP
- Clean Code
- Naming (my bad englisch leads to bad naming)
Interface CommandLineInterpreter
any class that implements this interface can be use the CommandLineInterface
. M
is the application, which implements the CommandLineInterpreter
public interface CommandLineInterpreter<M> {
Set<Command<M>> getCommands();
Response executeCommand(String identifier, List<String> parameter);
}
Class Command
the Command
is responible to map in command typed via CLI into an action (method-call) on your app. To execute the command the Class is generic on M
(which is your app) so you can call these app-specific methods.
public abstract class Command<M> {
private final String identifier;
public Command(String identifier) {
this.identifier = identifier;
}
public abstract Response execute(M invoked, List<String> parameter);
public String getIdentifier() {
return identifier;
}
public boolean isIdentifier(String ident) {
return identifier.equals(ident);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Command command = (Command) o;
return Objects.equals(identifier, command.identifier);
}
@Override
public int hashCode() {
return Objects.hash(identifier);
}
}
Class Response
provides information if the execution of an command was successful or not.
public class Response {
private final String message;
private final String details;
private final Type type;
private Response(Type type, String message, String details) {
this.type = type;
this.message = message;
this.details = details;
}
public static Response fail(String message) {
return fail(message, "");
}
public static Response fail(String message, String details) {
return response(Type.FAILURE, message, details);
}
private static Response response(Type type, String message, String details) {
return new Response(type, message, details);
}
public static Response success() {
return success("ok", "");
}
public static Response success(String message) {
return success(message, "");
}
public static Response success(String message, String details) {
return response(Type.SUCCESS, message, details);
}
public boolean failed() {
return type == Type.FAILURE;
}
@Override
public String toString() {
return type.toString() + ":" + message + (details.isEmpty() ? "" : "
Details: " + details);
}
private enum Type {SUCCESS, FAILURE}
Class CommandLineInterface
this class handles the user input fromm command line. it is itself an CommandLineInterpreter
and offers two basic commands: help
and exit
.
public class CommandLineInterface implements CommandLineInterpreter<CommandLineInterface> {
private static final String COMMAND_SEPARATOR = " ";
private final CommandLineInterpreter cli;
private final InputStream input;
private final PrintStream output;
private boolean isRunning = true;
public CommandLineInterface(CommandLineInterpreter<?> cli, InputStream input, PrintStream output) {
if (cli == null || hasPredefinedCommands(cli.getCommands())) {
throw new RuntimeException("CommandLineInterpreter interface of " + cli + " is not properly implemented");
}
this.cli = cli;
this.input = input;
this.output = output;
}
private boolean hasPredefinedCommands(Set<? extends Command<?>> commands) {
return !Collections.disjoint(commands, getCommands());
}
public void start() {
Scanner scanner = new Scanner(input);
showHelp();
while (isRunning) {
output.print("$>");
String command = scanner.nextLine();
List<String> line = Arrays.asList(command.split(COMMAND_SEPARATOR));
String identifier = line.get(0);
List<String> parameters = line.subList(1, line.size());
if (isExecutableCommand(identifier)) {
Response response = executeCommand(identifier, parameters);
if (response.failed()) {
showResponse(response);
}
} else {
showHelp();
}
}
}
private boolean isExecutableCommand(String identifier) {
for (Command cmd : getAllCommands()) {
if (cmd.isIdentifier(identifier)) {
return true;
}
}
return false;
}
private void showHelp() {
Set<Command<?>> commands = getAllCommands();
output.println("help - these commands are available:");
commands.forEach(c -> output.printf(" - %sn", c.getIdentifier()));
}
private void showResponse(Response response) {
output.println(response);
}
@Override
public Set<Command<CommandLineInterface>> getCommands() {
Set<Command<CommandLineInterface>> cliCommands = new HashSet<>();
cliCommands.add(new Command<CommandLineInterface>("exit") {
@Override
public Response execute(CommandLineInterface commandLineInterface, List<String> parameter) {
isRunning = false;
return Response.success();
}
});
cliCommands.add(new Command<CommandLineInterface>("help") {
@Override
public Response execute(CommandLineInterface commandLineInterface, List<String> parameter) {
showHelp();
return Response.success();
}
});
return cliCommands;
}
private Set<Command<?>> getAllCommands() {
Set<Command<?>> commands = mapCommands(cli.getCommands());
commands.addAll(getCommands());
return commands;
}
private Set<Command<?>> mapCommands(Set commands) {
Set<Command<?>> mappedCommands = new HashSet<>();
for (Object o : commands) mapCommand(o).ifPresent(mappedCommands::add);
return mappedCommands;
}
private Optional<Command<?>> mapCommand(Object o) {
return (o instanceof Command<?>) ? Optional.of((Command<?>) o) : Optional.empty();
}
@Override
public Response executeCommand(String identifier, List<String> parameter) {
Optional<Command<CommandLineInterface>> cmd = getCommands().stream().filter(command -> command.isIdentifier(identifier)).findAny();
if (cmd.isPresent()) {
return cmd.get().execute(this, parameter);
} else {
return cli.executeCommand(identifier, parameter);
}
}
}
Example
if you have implementet the interfaces properly you should have easy to use CLI support for your apps:
public static void main(String args) {
ExampleApplication app = new ExampleApplication();//implements CommandLineInterpreter
CommandLineInterface commandLineInterface = new CommandLineInterface(app, System.in, System.out);
commandLineInterface.start();
}
Output
this is an example output from an example app that does not much...
help - these commands are available:
- exampleCommand
- help
- exit
$>help
help - these commands are available:
- exampleCommand
- help
- exit
$>exampleCommand p1 p2 p3
i could do some actual work now if i were not a mere example, parameter [p1, p2, p3]
$>exit
Process finished with exit code 0
java object-oriented
$endgroup$
I wrote got a lot of mini apps. Each app has it's own InputHandler for Input from the keyboard. It's time to make a lib for that purpose - a CommandLineInterface
.
Can you review my code on
- Design
- OOP
- Clean Code
- Naming (my bad englisch leads to bad naming)
Interface CommandLineInterpreter
any class that implements this interface can be use the CommandLineInterface
. M
is the application, which implements the CommandLineInterpreter
public interface CommandLineInterpreter<M> {
Set<Command<M>> getCommands();
Response executeCommand(String identifier, List<String> parameter);
}
Class Command
the Command
is responible to map in command typed via CLI into an action (method-call) on your app. To execute the command the Class is generic on M
(which is your app) so you can call these app-specific methods.
public abstract class Command<M> {
private final String identifier;
public Command(String identifier) {
this.identifier = identifier;
}
public abstract Response execute(M invoked, List<String> parameter);
public String getIdentifier() {
return identifier;
}
public boolean isIdentifier(String ident) {
return identifier.equals(ident);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Command command = (Command) o;
return Objects.equals(identifier, command.identifier);
}
@Override
public int hashCode() {
return Objects.hash(identifier);
}
}
Class Response
provides information if the execution of an command was successful or not.
public class Response {
private final String message;
private final String details;
private final Type type;
private Response(Type type, String message, String details) {
this.type = type;
this.message = message;
this.details = details;
}
public static Response fail(String message) {
return fail(message, "");
}
public static Response fail(String message, String details) {
return response(Type.FAILURE, message, details);
}
private static Response response(Type type, String message, String details) {
return new Response(type, message, details);
}
public static Response success() {
return success("ok", "");
}
public static Response success(String message) {
return success(message, "");
}
public static Response success(String message, String details) {
return response(Type.SUCCESS, message, details);
}
public boolean failed() {
return type == Type.FAILURE;
}
@Override
public String toString() {
return type.toString() + ":" + message + (details.isEmpty() ? "" : "
Details: " + details);
}
private enum Type {SUCCESS, FAILURE}
Class CommandLineInterface
this class handles the user input fromm command line. it is itself an CommandLineInterpreter
and offers two basic commands: help
and exit
.
public class CommandLineInterface implements CommandLineInterpreter<CommandLineInterface> {
private static final String COMMAND_SEPARATOR = " ";
private final CommandLineInterpreter cli;
private final InputStream input;
private final PrintStream output;
private boolean isRunning = true;
public CommandLineInterface(CommandLineInterpreter<?> cli, InputStream input, PrintStream output) {
if (cli == null || hasPredefinedCommands(cli.getCommands())) {
throw new RuntimeException("CommandLineInterpreter interface of " + cli + " is not properly implemented");
}
this.cli = cli;
this.input = input;
this.output = output;
}
private boolean hasPredefinedCommands(Set<? extends Command<?>> commands) {
return !Collections.disjoint(commands, getCommands());
}
public void start() {
Scanner scanner = new Scanner(input);
showHelp();
while (isRunning) {
output.print("$>");
String command = scanner.nextLine();
List<String> line = Arrays.asList(command.split(COMMAND_SEPARATOR));
String identifier = line.get(0);
List<String> parameters = line.subList(1, line.size());
if (isExecutableCommand(identifier)) {
Response response = executeCommand(identifier, parameters);
if (response.failed()) {
showResponse(response);
}
} else {
showHelp();
}
}
}
private boolean isExecutableCommand(String identifier) {
for (Command cmd : getAllCommands()) {
if (cmd.isIdentifier(identifier)) {
return true;
}
}
return false;
}
private void showHelp() {
Set<Command<?>> commands = getAllCommands();
output.println("help - these commands are available:");
commands.forEach(c -> output.printf(" - %sn", c.getIdentifier()));
}
private void showResponse(Response response) {
output.println(response);
}
@Override
public Set<Command<CommandLineInterface>> getCommands() {
Set<Command<CommandLineInterface>> cliCommands = new HashSet<>();
cliCommands.add(new Command<CommandLineInterface>("exit") {
@Override
public Response execute(CommandLineInterface commandLineInterface, List<String> parameter) {
isRunning = false;
return Response.success();
}
});
cliCommands.add(new Command<CommandLineInterface>("help") {
@Override
public Response execute(CommandLineInterface commandLineInterface, List<String> parameter) {
showHelp();
return Response.success();
}
});
return cliCommands;
}
private Set<Command<?>> getAllCommands() {
Set<Command<?>> commands = mapCommands(cli.getCommands());
commands.addAll(getCommands());
return commands;
}
private Set<Command<?>> mapCommands(Set commands) {
Set<Command<?>> mappedCommands = new HashSet<>();
for (Object o : commands) mapCommand(o).ifPresent(mappedCommands::add);
return mappedCommands;
}
private Optional<Command<?>> mapCommand(Object o) {
return (o instanceof Command<?>) ? Optional.of((Command<?>) o) : Optional.empty();
}
@Override
public Response executeCommand(String identifier, List<String> parameter) {
Optional<Command<CommandLineInterface>> cmd = getCommands().stream().filter(command -> command.isIdentifier(identifier)).findAny();
if (cmd.isPresent()) {
return cmd.get().execute(this, parameter);
} else {
return cli.executeCommand(identifier, parameter);
}
}
}
Example
if you have implementet the interfaces properly you should have easy to use CLI support for your apps:
public static void main(String args) {
ExampleApplication app = new ExampleApplication();//implements CommandLineInterpreter
CommandLineInterface commandLineInterface = new CommandLineInterface(app, System.in, System.out);
commandLineInterface.start();
}
Output
this is an example output from an example app that does not much...
help - these commands are available:
- exampleCommand
- help
- exit
$>help
help - these commands are available:
- exampleCommand
- help
- exit
$>exampleCommand p1 p2 p3
i could do some actual work now if i were not a mere example, parameter [p1, p2, p3]
$>exit
Process finished with exit code 0
java object-oriented
java object-oriented
asked 7 mins ago
Martin FrankMartin Frank
630319
630319
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "196"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f214300%2fjava-commandline-interface-implementation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f214300%2fjava-commandline-interface-implementation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown