diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2017-10-08 22:39:59 -0300 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2017-10-08 22:39:59 -0300 |
| commit | c82e3b3b2de0633317ec8fc85925e91422820597 (patch) | |
| tree | 96567416ce23c5ce85601f9cedc3a94bb1c55cba /BJC-Utils2/src/main/java/bjc/utils/cli/objects/Command.java | |
| parent | b3ac1c8690c3e14c879913e5dcc03a5f5e14876e (diff) | |
Start splitting into maven modules
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/cli/objects/Command.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/cli/objects/Command.java | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/objects/Command.java b/BJC-Utils2/src/main/java/bjc/utils/cli/objects/Command.java deleted file mode 100644 index e605a2b..0000000 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/objects/Command.java +++ /dev/null @@ -1,87 +0,0 @@ -package bjc.utils.cli.objects; - -public class Command { - /** - * Command status values. - */ - public static enum CommandStatus { - /** - * The command succeded. - */ - SUCCESS, - /** - * The command failed non-fatally. - */ - FAIL, - /** - * The command failed fatally. - */ - ERROR, - /** - * The command was the last one. - */ - FINISH, - } - - public final int lineNo; - - public final String fullCommand; - public final String remnCommand; - public final String nameCommand; - - public final String ioSource; - - /** - * Create a new command. - * - * @param ln - * The line to get the command from. - * @param lno - * The number of the line the command came from. - * @param ioSrc - * The name of where the I/O came from. - */ - public Command(String ln, int lno, String ioSrc) { - int idx = ln.indexOf(' '); - - if(idx == -1) idx = ln.length(); - - fullCommand = ln; - nameCommand = ln.substring(0, idx).trim(); - remnCommand = ln.substring(idx).trim(); - - lineNo = lno; - - ioSource = ioSrc; - } - - public static Command fromString(String ln, int lno, String ioSource) { - /* - * Ignore blank lines and comments. - */ - if(ln.equals("")) return null; - if(ln.startsWith("#")) return null; - - /* - * Trim off comments part-way through the line. - */ - int idxHash = ln.indexOf('#'); - if(idxHash != -1) { - ln = ln.substring(0, idxHash).trim(); - } - - return new Command(ln, lno, ioSource); - } - - public String warn(String warning, Object... parms) { - String msg = String.format(warning, parms); - - return String.format("WARNING (%s:%d): %s", ioSource, lineNo, msg); - } - - public String error(String err, Object... parms) { - String msg = String.format(err, parms); - - return String.format("ERROR (%s:%d): %s", ioSource, lineNo, msg); - } -} |
