Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
cstamas committed Mar 20, 2024
1 parent 7abd484 commit 7a2ea39
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,21 @@
package eu.maveniverse.maven.toolbox.cli;

import eu.maveniverse.maven.mima.context.Context;
import eu.maveniverse.maven.toolbox.shared.ToolboxCommando;
import java.util.Collections;
import picocli.CommandLine;

/**
* List plugins.
*/
@CommandLine.Command(name = "listPlugins", description = "List plugins")
public final class ListPlugins extends ResolverCommandSupport {
@CommandLine.Command(name = "listAvailablePlugins", description = "List available plugins")
public final class ListAvailablePlugins extends ResolverCommandSupport {

@CommandLine.Parameters(index = "0", description = "The G to list")
private String g;

@Override
protected Integer doCall(Context context) throws Exception {
// Toolbox toolbox = Toolbox.getOrCreate(context);
//
// toolbox.listAvailablePlugins(Collections.singletonList(g), context.remoteRepositories()).stream()
// .sorted(Comparator.comparing(ArtifactIdUtils::toId))
// .forEach(p -> info(p.toString()));
return 0;
return ToolboxCommando.getOrCreate(context).listAvailablePlugins(Collections.singletonList(g), logger) ? 0 : 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
Identify.class,
Install.class,
List.class,
ListPlugins.class,
ListAvailablePlugins.class,
Search.class,
Record.class,
Repl.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import eu.maveniverse.maven.toolbox.shared.internal.ToolboxCommandoImpl;
import java.io.Closeable;
import java.io.IOException;
import java.util.List;
import org.eclipse.aether.repository.RemoteRepository;
import org.slf4j.Logger;

Expand Down Expand Up @@ -67,6 +68,8 @@ static void unset(Context context) {

boolean classpath(ResolutionScope resolutionScope, ResolutionRoot resolutionRoot, Logger output);

boolean listAvailablePlugins(List<String> groupIds, Logger output);

boolean tree(ResolutionScope resolutionScope, ResolutionRoot resolutionRoot, boolean verbose, Logger output);

// Search API related commands: they target one single RemoteRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.apache.maven.search.api.MAVEN;
Expand Down Expand Up @@ -106,6 +107,12 @@ public boolean classpath(ResolutionScope resolutionScope, ResolutionRoot resolut
}
}

@Override
public boolean listAvailablePlugins(List<String> groupIds, Logger output) {
toolboxResolver.listAvailablePlugins(groupIds).forEach(p -> output.info(p.toString()));
return true;
}

@Override
public boolean tree(
ResolutionScope resolutionScope, ResolutionRoot resolutionRoot, boolean verbose, Logger output) {
Expand Down

0 comments on commit 7a2ea39

Please sign in to comment.