Skip to content

Commit

Permalink
devonfw#188: add alias for versionCommandlet on demand (devonfw#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
slskiba authored Aug 8, 2024
1 parent ba83c94 commit bcb8b9f
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void testCompleteEmpty() {
AbstractIdeContext context = IdeTestContextMock.get();
CliArguments args = CliArguments.ofCompletion("");
args.next();
List<String> expectedCandidates = getExpectedCandidates(context, true, includeContextOptions);
List<String> expectedCandidates = getExpectedCandidates(context, true, includeContextOptions, true);
// act
List<CompletionCandidate> candidates = context.complete(args, includeContextOptions);
// assert
Expand All @@ -45,7 +45,7 @@ public void testCompleteEmptyNoCtxOptions() {
AbstractIdeContext context = IdeTestContextMock.get();
CliArguments args = CliArguments.ofCompletion("");
args.next();
List<String> expectedCandidates = getExpectedCandidates(context, true, includeContextOptions);
List<String> expectedCandidates = getExpectedCandidates(context, true, includeContextOptions, true);
// act
List<CompletionCandidate> candidates = context.complete(args, includeContextOptions);
// assert
Expand Down Expand Up @@ -100,9 +100,7 @@ public void testCompleteHelpEmptyArgs() {
// arrange
AbstractIdeContext context = IdeTestContextMock.get();
CliArguments args = CliArguments.ofCompletion("help", "");
List<String> expectedCandidates = getExpectedCandidates(context, true, false);
// TODO: fix the hacky workaround, see: https://github.com/devonfw/IDEasy/issues/188
expectedCandidates.remove("-v"); // hackish solution, improve me please
List<String> expectedCandidates = getExpectedCandidates(context, true, false, false);
// act
List<CompletionCandidate> candidates = context.complete(args, true);
// assert
Expand All @@ -124,7 +122,7 @@ public void testCompleteVersionNoMoreArgs() {
}

private static List<String> getExpectedCandidates(AbstractIdeContext context, boolean commandlets,
boolean ctxOptions) {
boolean ctxOptions, boolean addVersionAlias) {

List<String> expectedCandidates = new ArrayList<>();
if (ctxOptions) {
Expand All @@ -141,7 +139,9 @@ private static List<String> getExpectedCandidates(AbstractIdeContext context, bo
for (Commandlet cmd : context.getCommandletManager().getCommandlets()) {
expectedCandidates.add(cmd.getName());
}
expectedCandidates.add("-v"); // alias for VersionCommandlet (--version)
if (addVersionAlias) {
expectedCandidates.add("-v"); // alias for VersionCommandlet (--version)
}
}
Collections.sort(expectedCandidates);
return expectedCandidates;
Expand Down

0 comments on commit bcb8b9f

Please sign in to comment.