branch develop updated (06f4e11 -> 1292191)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository nuiton-config. See https://gitlab.nuiton.org/nuiton/nuiton-config.git from 06f4e11 Do not store option value for value equals to default option (Fixes #1807) new 1292191 Allow application config to execute action on provided class instance (Fixes #2090) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 12921911a58b2b7a3ccae36a93cc197c93fa08c7 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Oct 2 11:01:47 2016 +0200 Allow application config to execute action on provided class instance (Fixes #2090) Summary of changes: .../java/org/nuiton/config/ApplicationConfig.java | 10 ++++++++-- .../java/org/nuiton/config/ApplicationConfigTest.java | 19 +++++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository nuiton-config. See https://gitlab.nuiton.org/nuiton/nuiton-config.git commit 12921911a58b2b7a3ccae36a93cc197c93fa08c7 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Oct 2 11:01:47 2016 +0200 Allow application config to execute action on provided class instance (Fixes #2090) --- .../java/org/nuiton/config/ApplicationConfig.java | 10 ++++++++-- .../java/org/nuiton/config/ApplicationConfigTest.java | 19 +++++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/nuiton-config/src/main/java/org/nuiton/config/ApplicationConfig.java b/nuiton-config/src/main/java/org/nuiton/config/ApplicationConfig.java index fae7728..0974377 100644 --- a/nuiton-config/src/main/java/org/nuiton/config/ApplicationConfig.java +++ b/nuiton-config/src/main/java/org/nuiton/config/ApplicationConfig.java @@ -2030,6 +2030,12 @@ public class ApplicationConfig { InvocationTargetException { Action result = null; + if (name.startsWith("this#")) { + + // To use the application config class directly + name = getClass().getName() + "#" + StringUtils.removeStart(name, "this#"); + } + List<Method> methods = ObjectUtil.getMethod(name, true); Class clazz = null; @@ -2237,8 +2243,8 @@ public class ApplicationConfig { break; } if (arg.startsWith("--")) { - String optionName = arg.substring(2); - Action action = createAction(optionName, i); + String actionName = arg.substring(2); + Action action = createAction(actionName, i); addAction(action); } } diff --git a/nuiton-config/src/test/java/org/nuiton/config/ApplicationConfigTest.java b/nuiton-config/src/test/java/org/nuiton/config/ApplicationConfigTest.java index 506b299..35d45e7 100644 --- a/nuiton-config/src/test/java/org/nuiton/config/ApplicationConfigTest.java +++ b/nuiton-config/src/test/java/org/nuiton/config/ApplicationConfigTest.java @@ -90,7 +90,7 @@ public class ApplicationConfigTest { @Test public void saveForUser() throws IOException { - // Initiliaze path and filename + // Initialize path and filename String path = testDirectory.getAbsolutePath(); String oldHome = SystemUtils.getUserHome().getAbsolutePath(); @@ -142,7 +142,7 @@ public class ApplicationConfigTest { @Test public void cleanUserConfig() throws IOException, ArgumentsParserException { - // Initiliaze path and filename + // Initialize path and filename String path = testDirectory.getAbsolutePath(); String oldHome = SystemUtils.getUserHome().getAbsolutePath(); @@ -270,6 +270,21 @@ public class ApplicationConfigTest { Assert.assertEquals(1, DUMMY_ACTION_CALL); } + + @Test + public void doActionOnApplicationConfig() throws Exception { + ApplicationConfig instance = new ApplicationConfig(); + + instance.parse("--this#printConfig"); + + Map<Integer, List<Action>> actions = instance.actions; + + Assert.assertFalse(actions.isEmpty()); + Assert.assertTrue(actions.containsKey(0)); + + instance.doAction(0); + } + @Test public void setUseOnlyAliases() { ApplicationConfig instance = new ApplicationConfig(); -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm