diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-22 14:48:04 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-22 14:48:04 -0400 |
| commit | 42f7d379a430aaf2fad169f0170de04072b08b10 (patch) | |
| tree | 5d46b43b2d9272f4e593820ee147b3ae3f0d82b0 /BJC-Utils2/src/main/java/bjc/utils/cli | |
| parent | b65b705c391bb772bc41269bce5243c1cc88969d (diff) | |
Formatting changes
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/cli')
7 files changed, 75 insertions, 75 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java b/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java index e816b78..09d3da7 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java @@ -48,21 +48,6 @@ public class CLICommander { } /** - * Set the initial command mode to use - * - * @param initialMode - * The initial command mode to use - */ - public void setInitialCommandMode(ICommandMode initialMode) { - if (initialMode == null) { - throw new NullPointerException( - "Initial mode must be non-zero"); - } - - this.initialMode = initialMode; - } - - /** * Run a set of commands through this commander */ public void runCommands() { @@ -105,4 +90,19 @@ public class CLICommander { normalOutput.print("Exiting now."); } + + /** + * Set the initial command mode to use + * + * @param initialMode + * The initial command mode to use + */ + public void setInitialCommandMode(ICommandMode initialMode) { + if (initialMode == null) { + throw new NullPointerException( + "Initial mode must be non-zero"); + } + + this.initialMode = initialMode; + } } diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/DelegatingCommand.java b/BJC-Utils2/src/main/java/bjc/utils/cli/DelegatingCommand.java index 76794cf..28e0347 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/DelegatingCommand.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/DelegatingCommand.java @@ -8,6 +8,11 @@ class DelegatingCommand implements ICommand { } @Override + public ICommand createAlias() { + return new DelegatingCommand(delegate); + } + + @Override public ICommandHandler getHandler() { return delegate.getHandler(); } @@ -18,11 +23,6 @@ class DelegatingCommand implements ICommand { } @Override - public ICommand createAlias() { - return new DelegatingCommand(delegate); - } - - @Override public boolean isAlias() { return true; } diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/GenericCommand.java b/BJC-Utils2/src/main/java/bjc/utils/cli/GenericCommand.java index 3c0aef6..fad1199 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/GenericCommand.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/GenericCommand.java @@ -26,6 +26,16 @@ public class GenericCommand implements ICommand { this.help = new GenericHelp(description, help); } + /** + * Create a command that is an alias to this one + * + * @return A command that is an alias to this one + */ + @Override + public ICommand createAlias() { + return new DelegatingCommand(this); + } + @Override public ICommandHandler getHandler() { return handler; @@ -40,14 +50,4 @@ public class GenericCommand implements ICommand { public boolean isAlias() { return false; } - - /** - * Create a command that is an alias to this one - * - * @return A command that is an alias to this one - */ - @Override - public ICommand createAlias() { - return new DelegatingCommand(this); - } } diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/GenericHelp.java b/BJC-Utils2/src/main/java/bjc/utils/cli/GenericHelp.java index f508de8..f2fb146 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/GenericHelp.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/GenericHelp.java @@ -24,13 +24,13 @@ public class GenericHelp implements ICommandHelp { } @Override - public String getSummary() { - return summary; + public String getDescription() { + return description; } @Override - public String getDescription() { - return description; + public String getSummary() { + return summary; } }
\ No newline at end of file diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/ICommand.java b/BJC-Utils2/src/main/java/bjc/utils/cli/ICommand.java index 7029829..ff15a37 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/ICommand.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/ICommand.java @@ -8,6 +8,13 @@ package bjc.utils.cli; */ public interface ICommand { /** + * Create a command that serves as an alias to this one + * + * @return A command that serves as an alias to this one + */ + public ICommand createAlias(); + + /** * Get the handler that executes this command * * @return The handler that executes this command @@ -22,13 +29,6 @@ public interface ICommand { public ICommandHelp getHelp(); /** - * Create a command that serves as an alias to this one - * - * @return A command that serves as an alias to this one - */ - public ICommand createAlias(); - - /** * Check if this command is an alias of another command * * @return Whether or not this command is an alias of another diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandHelp.java b/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandHelp.java index ad03dac..d475335 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandHelp.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandHelp.java @@ -8,6 +8,13 @@ package bjc.utils.cli; */ public interface ICommandHelp { /** + * Get the description of a command + * + * @return The description of a command + */ + public String getDescription(); + + /** * Get the summary line for a command * * Used for 'help commands' which gives the user a brief idea what all @@ -16,11 +23,4 @@ public interface ICommandHelp { * @return The summary line line for a command */ public String getSummary(); - - /** - * Get the description of a command - * - * @return The description of a command - */ - public String getDescription(); } diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandMode.java b/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandMode.java index 5208657..f6313af 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandMode.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandMode.java @@ -9,21 +9,6 @@ package bjc.utils.cli; */ public interface ICommandMode { /** - * Process a command in this mode - * - * @param command - * The command to process - * @param args - * A list of arguments to the command - * @return The command mode to use for the next command. Defaults to - * returning this, and doing nothing else - */ - public default ICommandMode processCommand(String command, - String[] args) { - return this; - }; - - /** * Check to see if this mode can handle the specified command * * @param command @@ -33,6 +18,19 @@ public interface ICommandMode { */ public default boolean canHandleCommand(String command) { return false; + }; + + /** + * Get the custom prompt for this mode + * + * @return the custom prompt for this mode + * + * @throws UnsupportedOperationException + * if this mode doesn't support a custom prompt + */ + public default String getCustomPrompt() { + throw new UnsupportedOperationException( + "This mode doesn't support a custom prompt"); } /** @@ -45,24 +43,26 @@ public interface ICommandMode { } /** - * Check if this mode uses a custom prompt + * Process a command in this mode * - * @return Whether or not this mode uses a custom prompt + * @param command + * The command to process + * @param args + * A list of arguments to the command + * @return The command mode to use for the next command. Defaults to + * returning this, and doing nothing else */ - public default boolean useCustomPrompt() { - return false; + public default ICommandMode processCommand(String command, + String[] args) { + return this; } /** - * Get the custom prompt for this mode - * - * @return the custom prompt for this mode + * Check if this mode uses a custom prompt * - * @throws UnsupportedOperationException - * if this mode doesn't support a custom prompt + * @return Whether or not this mode uses a custom prompt */ - public default String getCustomPrompt() { - throw new UnsupportedOperationException( - "This mode doesn't support a custom prompt"); + public default boolean useCustomPrompt() { + return false; } } |
