Skip to content

Commit

Permalink
channel list output is confusing #755
Browse files Browse the repository at this point in the history
  • Loading branch information
parsharma committed Oct 16, 2024
1 parent c4a6f65 commit 660c709
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
import java.util.Optional;

import org.wildfly.channel.Channel;
import org.wildfly.channel.ChannelMapper;
import org.wildfly.prospero.actions.MetadataAction;
import org.wildfly.prospero.cli.ActionFactory;
import org.wildfly.prospero.cli.CliConsole;
import org.wildfly.prospero.cli.CliMessages;
import org.wildfly.prospero.cli.ReturnCodes;
import org.wildfly.prospero.cli.printers.ChannelPrinter;
import org.wildfly.prospero.metadata.ManifestVersionRecord;
import picocli.CommandLine;

Expand All @@ -53,6 +53,9 @@ public static class ChannelListCommand extends AbstractCommand {
@CommandLine.Option(names = CliConstants.DIR)
Optional<Path> directory;

@CommandLine.Option(names = CliConstants.FULL)
boolean fullList;

public ChannelListCommand(CliConsole console, ActionFactory actionFactory) {
super(console, actionFactory);
}
Expand All @@ -68,11 +71,13 @@ public Integer call() throws Exception {
channels = metadataAction.getChannels();
}

final ChannelPrinter channelPrinter = new ChannelPrinter(console);
console.println("-------");
for (Channel channel : channels) {
channelPrinter.print(channel);
console.println("-------");
if (fullList) {
console.println(ChannelMapper.toYaml(channels));
} else {
console.println(channel.getName() + " " + channel.getManifestCoordinate().getGroupId() + ":" + channel.getManifestCoordinate().getArtifactId() + ":" +
channel.getManifestCoordinate().getVersion() + "\n");
}
}

return ReturnCodes.SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ private Commands() {
public static final String DIR = "--dir";
public static final String FEATURE_PACK_REFERENCE = "<feature-pack-reference>";
public static final String FPL = "--fpl";
public static final String FULL = "--full";
public static final String H = "-h";
public static final String HELP = "--help";
public static final String LAYERS = "--layers";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,33 @@ public void testList() {
int exitCode = commandLine.execute(CliConstants.Commands.CHANNEL, CliConstants.Commands.LIST,
CliConstants.DIR, dir.toString());
Assert.assertEquals(ReturnCodes.SUCCESS, exitCode);
Assert.assertEquals(3, getStandardOutput().lines().filter(l->l.contains("manifest")).count());
Assert.assertEquals(3, getStandardOutput().lines()
.filter(line -> line.matches(".*\\S+ \\S+:\\S+:\\S+")) // Check if the line contains a name and manifest details
.count());
}

@Test
public void testFullList() {
int exitCode = commandLine.execute(CliConstants.Commands.CHANNEL, CliConstants.Commands.LIST, CliConstants.FULL,
CliConstants.DIR, dir.toString());
Assert.assertEquals(ReturnCodes.SUCCESS, exitCode);
String output = getStandardOutput();
Assert.assertTrue("Expected 'schemaVersion' in the output",
output.contains("schemaVersion"));
Assert.assertTrue("Expected 'name' in the output",
output.contains("name"));
Assert.assertTrue("Expected 'repositories' in the output",
output.contains("repositories"));
Assert.assertTrue("Expected 'manifest' in the output",
output.contains("manifest"));
Assert.assertTrue("Expected 'maven' in the output",
output.contains("maven"));
Assert.assertTrue("Expected 'groupId' in the output",
output.contains("groupId"));
Assert.assertTrue("Expected 'artifactId' in the output",
output.contains("artifactId"));
Assert.assertTrue("Expected 'version' in the output",
output.contains("version"));
}

@Test
Expand Down

0 comments on commit 660c709

Please sign in to comment.