Skip to content

Commit 3d73fce

Browse files
committed
ConsoleArguments: rename aliases to flags
"Alias" would imply that there is one canonical way to invoke a given ConsoleArgument.
1 parent f6732d9 commit 3d73fce

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/main/java/org/scijava/console/AbstractConsoleArgument.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,28 @@ public abstract class AbstractConsoleArgument extends
4646
AbstractHandlerPlugin<LinkedList<String>> implements ConsoleArgument
4747
{
4848
private int numArgs;
49-
private Set<String> aliasFlags;
49+
private Set<String> flags;
5050

5151
public AbstractConsoleArgument() {
5252
this(1, new String[0]);
5353
}
5454

55-
public AbstractConsoleArgument(final String... aliases) {
56-
this(1, aliases);
55+
public AbstractConsoleArgument(final String... flags) {
56+
this(1, flags);
5757
}
5858

59-
public AbstractConsoleArgument(final int requiredArgs, final String... aliases) {
59+
public AbstractConsoleArgument(final int requiredArgs, final String... flags) {
6060
numArgs = requiredArgs;
61-
aliasFlags = new HashSet<String>();
62-
for (final String s : aliases) aliasFlags.add(s);
61+
this.flags = new HashSet<String>();
62+
for (final String s : flags) this.flags.add(s);
6363
}
6464

6565
// -- Typed methods --
6666

6767
@Override
6868
public boolean supports(final LinkedList<String> args) {
6969
if (args == null || args.size() < numArgs) return false;
70-
return isAlias(args);
70+
return isFlag(args);
7171
}
7272

7373
@Override
@@ -77,11 +77,13 @@ public Class<LinkedList<String>> getType() {
7777
}
7878

7979
/**
80-
* @return true if there are no aliases for this {@code ConsoleArgument}, or
81-
* at least one alias matches the first argument in the provided
82-
* list
80+
* Check if the given list of arguments starts with a flag that matches this
81+
* {@link ConsoleArgument}.
82+
*
83+
* @return true iff one of this argument's flags matches the first string in
84+
* the given list, or this argument has no explicit flags.
8385
*/
84-
protected boolean isAlias(final LinkedList<String> args) {
85-
return aliasFlags.isEmpty() || aliasFlags.contains(args.getFirst());
86+
protected boolean isFlag(final LinkedList<String> args) {
87+
return flags.isEmpty() || flags.contains(args.getFirst());
8688
}
8789
}

src/main/java/org/scijava/main/console/MainArgument.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void handle(final LinkedList<String> args) {
7373
final String className = args.removeFirst();
7474

7575
final List<String> argList = new ArrayList<String>();
76-
while (!args.isEmpty() && !isAlias(args) && !isSeparator(args)) {
76+
while (!args.isEmpty() && !isFlag(args) && !isSeparator(args)) {
7777
argList.add(args.removeFirst());
7878
}
7979
if (isSeparator(args)) args.removeFirst(); // remove the -- separator

0 commit comments

Comments
 (0)