[java-identity-provider] branch main updated: Update ANSI code API and enable option in module.sh
Scott Cantor
cantor.2 at osu.edu
Wed Oct 14 13:44:00 UTC 2020
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=9501c116c3b87ba9ee073764d966e1fe7673f61a
The following commit(s) were added to refs/heads/main by this push:
new 9501c116c Update ANSI code API and enable option in module.sh
9501c116c is described below
commit 9501c116c3b87ba9ee073764d966e1fe7673f61a
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Oct 14 09:43:23 2020 -0400
Update ANSI code API and enable option in module.sh
---
.../idp/module/impl/ModuleManagerArguments.java | 4 ++--
.../idp/module/impl/ModuleManagerCLI.java | 24 ++++++++++++++--------
idp-distribution/src/main/resources/bin/module.sh | 2 +-
3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/idp-admin-impl/src/main/java/net/shibboleth/idp/module/impl/ModuleManagerArguments.java b/idp-admin-impl/src/main/java/net/shibboleth/idp/module/impl/ModuleManagerArguments.java
index acb2dfd3f..1a1677dec 100644
--- a/idp-admin-impl/src/main/java/net/shibboleth/idp/module/impl/ModuleManagerArguments.java
+++ b/idp-admin-impl/src/main/java/net/shibboleth/idp/module/impl/ModuleManagerArguments.java
@@ -137,10 +137,10 @@ public class ModuleManagerArguments extends AbstractIdPHomeAwareCommandLineArgum
super.validate();
if (getEnableModuleIds().isEmpty() && getDisableModuleIds().isEmpty()) {
- if (getInfoModuleIds().isEmpty()) {
+ if (getInfoModuleIds().isEmpty() && getTestModuleIds().isEmpty()) {
list = true;
}
- } else if (list || !getInfoModuleIds().isEmpty()) {
+ } else if (list || !getInfoModuleIds().isEmpty() || !getTestModuleIds().isEmpty()) {
getLog().error("Cannot query and enable/disable in the same operation");
throw new IllegalArgumentException("Cannot query and enable/disable in the same operation.");
}
diff --git a/idp-admin-impl/src/main/java/net/shibboleth/idp/module/impl/ModuleManagerCLI.java b/idp-admin-impl/src/main/java/net/shibboleth/idp/module/impl/ModuleManagerCLI.java
index da46da1af..c8e609258 100644
--- a/idp-admin-impl/src/main/java/net/shibboleth/idp/module/impl/ModuleManagerCLI.java
+++ b/idp-admin-impl/src/main/java/net/shibboleth/idp/module/impl/ModuleManagerCLI.java
@@ -99,19 +99,20 @@ public final class ModuleManagerCLI extends AbstractIdPHomeAwareCommandLine<Modu
moduleContext.setHttpClientSecurityParameters(getHttpClientSecurityParameters());
moduleContext.setLanguageRanges(args.getLanguageRanges());
- if (args.getList() || !args.getInfoModuleIds().isEmpty()) {
+ if (args.getList() || !args.getInfoModuleIds().isEmpty() || !args.getTestModuleIds().isEmpty()) {
return doList(moduleContext, args);
}
return doManage(moduleContext, args);
} catch (final ModuleException e) {
System.out.println(e.getMessage());
- System.out.println(ANSIColors.ANSI_RED + "[FAILED]" + ANSIColors.ANSI_RESET);
+ System.out.println(TerminalCodes.RED.code(args) + "[FAILED]" + TerminalCodes.RESET.code(args));
System.out.println();
return RC_INIT;
}
}
+// Checkstyle: CyclomaticComplexity OFF
/**
* List/report on modules.
*
@@ -143,9 +144,11 @@ public final class ModuleManagerCLI extends AbstractIdPHomeAwareCommandLine<Modu
System.out.println("\tDesc: " + module.getDescription(moduleContext));
System.out.println("\tHelp: " + module.getURL());
if (module.isEnabled(moduleContext)) {
- System.out.println("\tStatus: " + ANSIColors.ANSI_GREEN + "ENABLED" + ANSIColors.ANSI_RESET);
+ System.out.println("\tStatus: " +
+ TerminalCodes.GREEN.code(args) + "ENABLED" + TerminalCodes.RESET.code(args));
} else {
- System.out.println("\tStatus: " + ANSIColors.ANSI_RED + "DISABLED" + ANSIColors.ANSI_RESET);
+ System.out.println("\tStatus: " +
+ TerminalCodes.RED.code(args) + "DISABLED" + TerminalCodes.RESET.code(args));
}
final Collection<ModuleResource> resources = module.getResources();
resources.forEach(r -> {
@@ -153,13 +156,15 @@ public final class ModuleManagerCLI extends AbstractIdPHomeAwareCommandLine<Modu
r.getDestination());
});
System.out.println();
- } else if (args.getInfoModuleIds().isEmpty()) {
+ }
+
+ if (args.getInfoModuleIds().isEmpty() && args.getTestModuleIds().isEmpty()) {
if (module.isEnabled(moduleContext)) {
System.out.println("Module: " + module.getId() +
- ANSIColors.ANSI_GREEN + " [ENABLED]" + ANSIColors.ANSI_RESET);
+ TerminalCodes.GREEN.code(args) + " [ENABLED]" + TerminalCodes.RESET.code(args));
} else {
System.out.println("Module: " + module.getId() +
- ANSIColors.ANSI_RED + " [DISABLED]" + ANSIColors.ANSI_RESET);
+ TerminalCodes.RED.code(args) + " [DISABLED]" + TerminalCodes.RESET.code(args));
}
}
} catch (final ServiceConfigurationError e) {
@@ -169,7 +174,8 @@ public final class ModuleManagerCLI extends AbstractIdPHomeAwareCommandLine<Modu
return ret;
}
-
+// Checkstyle: CyclomaticComplexity ON
+
/**
* Manage modules as directed.
*
@@ -206,7 +212,7 @@ public final class ModuleManagerCLI extends AbstractIdPHomeAwareCommandLine<Modu
module.disable(moduleContext, args.getClean());
results.forEach(this::doReportOperation);
- System.out.println(ANSIColors.ANSI_GREEN + "[OK]" + ANSIColors.ANSI_RESET);
+ System.out.println(TerminalCodes.GREEN.code(args) + "[OK]" + TerminalCodes.RESET.code(args));
System.out.println();
final String msg = sink.toString(Charset.forName("UTF-8"));
diff --git a/idp-distribution/src/main/resources/bin/module.sh b/idp-distribution/src/main/resources/bin/module.sh
index 2cfe66657..92de057d4 100644
--- a/idp-distribution/src/main/resources/bin/module.sh
+++ b/idp-distribution/src/main/resources/bin/module.sh
@@ -4,4 +4,4 @@ declare LOCATION
LOCATION=$(dirname $0)
-$LOCATION/runclass.sh net.shibboleth.idp.module.impl.ModuleManagerCLI --home "$LOCATION/.." "$@"
+$LOCATION/runclass.sh net.shibboleth.idp.module.impl.ModuleManagerCLI --ansi --home "$LOCATION/.." "$@"
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list