Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implementing --skip-broken option #627

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ class CliOptions {
handler = MultiCredentialsOptionHandler.class)
private List<Credentials> credentials;

@Option(name = "--skip-broken", usage = "Lists skipped plugins when enabled", handler = BooleanOptionHandler.class)
private boolean skipBroken;

/**
* Creates a configuration class with configurations specified from the CLI and/or environment variables.
*
Expand Down Expand Up @@ -184,6 +187,7 @@ Config setup() {
.withSkipFailedPlugins(isSkipFailedPlugins())
.withCredentials(credentials)
.withHashFunction(getHashFunction())
.withSkipBroken(isSkipBroken())
.build();
}

Expand Down Expand Up @@ -343,6 +347,15 @@ public boolean isVerbose() {
return verbose;
}

/**
* Gets the value corresponding to if user selected to list skipped plugins
*
* @return true if user selected CLI Option to list skipped plugins
*/
private boolean isSkipBroken() {
return skipBroken;
}

/**
* Determines the update center url string. If a value is set via CLI option, it will override a value set via
* environment variable. If neither are set, the default in the Settings class will be used.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class Config {
private final List<Credentials> credentials;
private final Path cachePath;
private final LogOutput logOutput;
private final boolean skipBroken;

private Config(
File pluginDir,
Expand All @@ -80,7 +81,8 @@ private Config(
HashFunction hashFunction,
List<Credentials> credentials,
Path cachePath,
boolean hideWarnings) {
boolean hideWarnings,
boolean skipBroken) {
this.pluginDir = pluginDir;
this.cleanPluginDir = cleanPluginDir;
this.showWarnings = showWarnings;
Expand All @@ -105,6 +107,7 @@ private Config(
this.cachePath = cachePath;
this.logOutput = new LogOutput(verbose);
this.hideWarnings = hideWarnings;
this.skipBroken = skipBroken;
}

public File getPluginDir() {
Expand Down Expand Up @@ -213,6 +216,10 @@ public LogOutput getLogOutput() {
return logOutput;
}

public boolean isSkipBroken(){
return skipBroken;
}

public static class Builder {
private File pluginDir;
private boolean cleanPluginDir;
Expand All @@ -237,6 +244,7 @@ public static class Builder {
private List<Credentials> credentials = Collections.emptyList();
private HashFunction hashFunction = Settings.DEFAULT_HASH_FUNCTION;
private Path cachePath = Settings.DEFAULT_CACHE_PATH;
private boolean skipBroken;

private Builder() {
}
Expand Down Expand Up @@ -368,6 +376,11 @@ public Builder withCachePath(@NonNull Path cachePath) {
return this;
}

public Builder withSkipBroken(Boolean skipBroken){
this.skipBroken = skipBroken;
return this;
}

public Config build() {
return new Config(
pluginDir,
Expand All @@ -392,7 +405,8 @@ public Config build() {
hashFunction,
credentials,
cachePath,
hideWarnings
hideWarnings,
skipBroken
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,18 @@ public void start(boolean downloadUc) {
if (cfg.doDownload()) {
downloadPlugins(pluginsToBeDownloaded);
}
if(cfg.isSkipBroken()){
List<Plugin> failedPlugins = getFailedPlugins();
if(failedPlugins.isEmpty()){
System.out.println("No plugin is skipped");
}
else{
System.out.println("Following plugins are skipped due to failure:");
for(Plugin failedPlugin: failedPlugins){
System.out.println(failedPlugin.getName());
}
}
}
logMessage("Done");
}

Expand Down
Loading