[DEV] commit all with new insland

This commit is contained in:
Edouard DUPIN 2022-03-20 23:39:36 +01:00
parent 2935b4e474
commit 7dfde94a47
4 changed files with 71 additions and 65 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
/__pycache__/
# Compiled python modules. # Compiled python modules.
*.pyc *.pyc

View File

@ -1 +1,3 @@
/__pycache__/
/classes/ /classes/

View File

@ -16,9 +16,13 @@ public class ArgumentManager {
private final PropertiesInterface properties; private final PropertiesInterface properties;
private final boolean enableStoreConfig; private final boolean enableStoreConfig;
public ArgumentManager(final String[] args, final Object tmp) {
this(args, tmp, false);
}
public ArgumentManager(final String[] args, final Object tmp, final boolean enableStoreConfig) { public ArgumentManager(final String[] args, final Object tmp, final boolean enableStoreConfig) {
this.enableStoreConfig = enableStoreConfig; this.enableStoreConfig = enableStoreConfig;
for (int iii=0; iii<args.length; iii++) { for (int iii = 0; iii < args.length; iii++) {
this.arguments.add(args[iii]); this.arguments.add(args[iii]);
} }
this.properties = new PropertiesInterface(tmp.getClass()); this.properties = new PropertiesInterface(tmp.getClass());
@ -30,13 +34,10 @@ public class ArgumentManager {
} }
} }
public ArgumentManager(final String[] args, final Object tmp) {
this(args, tmp, false);
}
private void configure(final Object tmp) { private void configure(final Object tmp) {
boolean endParsing = false; boolean endParsing = false;
for (int iii=0; iii<this.arguments.size(); iii++) { for (int iii = 0; iii < this.arguments.size(); iii++) {
String value = this.arguments.get(iii); String value = this.arguments.get(iii);
if (endParsing) { if (endParsing) {
this.argumentResidual.add(value); this.argumentResidual.add(value);
@ -45,7 +46,7 @@ public class ArgumentManager {
if (value.startsWith("--")) { if (value.startsWith("--")) {
String[] elements = value.split("="); String[] elements = value.split("=");
elements[0] = elements[0].substring(2); elements[0] = elements[0].substring(2);
Log.warning("find element (--) : " + Arrays.toString(elements)); Log.verbose("find element (--) : " + Arrays.toString(elements));
String parameter = elements[0]; String parameter = elements[0];
String newValue = null; String newValue = null;
if (!this.properties.existParameter(parameter)) { if (!this.properties.existParameter(parameter)) {
@ -57,10 +58,10 @@ public class ArgumentManager {
Log.critical("Boolean parameter can not have parameters for '" + value + "'"); Log.critical("Boolean parameter can not have parameters for '" + value + "'");
} }
} else if (elements.length == 1) { } else if (elements.length == 1) {
if (iii==this.arguments.size()-1) { if (iii == this.arguments.size() - 1) {
Log.critical("Missing parameters for '" + value + "' (no more arguments)"); Log.critical("Missing parameters for '" + value + "' (no more arguments)");
} }
newValue = this.arguments.get(iii+1); newValue = this.arguments.get(iii + 1);
if (newValue.startsWith("-")) { if (newValue.startsWith("-")) {
Log.critical("Missing parameters for '" + value + "' (next argument is a parameter (start with '-'))"); Log.critical("Missing parameters for '" + value + "' (next argument is a parameter (start with '-'))");
} }
@ -90,10 +91,10 @@ public class ArgumentManager {
} }
} else if (elements.length == 1) { } else if (elements.length == 1) {
if (iii==this.arguments.size()-1) { if (iii == this.arguments.size() - 1) {
Log.critical("Missing parameters for '" + value + "' (no more arguments)"); Log.critical("Missing parameters for '" + value + "' (no more arguments)");
} }
newValue = this.arguments.get(iii+1); newValue = this.arguments.get(iii + 1);
if (newValue.startsWith("-")) { if (newValue.startsWith("-")) {
Log.critical("Missing parameters for '" + value + "' (next argument is a parameter (start with '-'))"); Log.critical("Missing parameters for '" + value + "' (next argument is a parameter (start with '-'))");
} }
@ -105,8 +106,8 @@ public class ArgumentManager {
} }
this.properties.setParameterAlias(tmp, parameter, newValue); this.properties.setParameterAlias(tmp, parameter, newValue);
} else { } else {
Log.warning("find element ( ) : " + value); Log.verbose("find element ( ) : " + value);
if (this.properties.actions!= null && this.properties.actions.exist(value)) { if (this.properties.actions != null && this.properties.actions.exist(value)) {
// Find end of parsing ... // Find end of parsing ...
endParsing = true; endParsing = true;
this.actionDetected = value; this.actionDetected = value;
@ -145,59 +146,59 @@ public class ArgumentManager {
Log.warning("Rejected executor, " + exec.getName() + " nbParameter=" + exec.getParameterCount() + " require=" + nbParameters); Log.warning("Rejected executor, " + exec.getName() + " nbParameter=" + exec.getParameterCount() + " require=" + nbParameters);
continue; continue;
} }
Log.warning("find executor, " + exec.getName()); Log.verbose("find executor, " + exec.getName());
try { try {
switch(nbParameters) { switch (nbParameters) {
case 0: case 0:
exec.invoke(obj); exec.invoke(obj);
break; break;
case 1: case 1:
exec.invoke(obj, exec.invoke(obj, //
localManager.argumentPostConfigure.get(0)); localManager.argumentPostConfigure.get(0));
break; break;
case 2: case 2:
exec.invoke(obj, exec.invoke(obj, //
localManager.argumentPostConfigure.get(0), localManager.argumentPostConfigure.get(0), //
localManager.argumentPostConfigure.get(1)); localManager.argumentPostConfigure.get(1));
break; break;
case 3: case 3:
exec.invoke(obj, exec.invoke(obj, //
localManager.argumentPostConfigure.get(0), localManager.argumentPostConfigure.get(0), //
localManager.argumentPostConfigure.get(1), localManager.argumentPostConfigure.get(1), //
localManager.argumentPostConfigure.get(2)); localManager.argumentPostConfigure.get(2));
break; break;
case 4: case 4:
exec.invoke(obj, exec.invoke(obj, //
localManager.argumentPostConfigure.get(0), localManager.argumentPostConfigure.get(0), //
localManager.argumentPostConfigure.get(1), localManager.argumentPostConfigure.get(1), //
localManager.argumentPostConfigure.get(2), localManager.argumentPostConfigure.get(2), //
localManager.argumentPostConfigure.get(3)); localManager.argumentPostConfigure.get(3));
break; break;
case 5: case 5:
exec.invoke(obj, exec.invoke(obj, //
localManager.argumentPostConfigure.get(0), localManager.argumentPostConfigure.get(0), //
localManager.argumentPostConfigure.get(1), localManager.argumentPostConfigure.get(1), //
localManager.argumentPostConfigure.get(2), localManager.argumentPostConfigure.get(2), //
localManager.argumentPostConfigure.get(3), localManager.argumentPostConfigure.get(3), //
localManager.argumentPostConfigure.get(4)); localManager.argumentPostConfigure.get(4));
break; break;
case 6: case 6:
exec.invoke(obj, exec.invoke(obj, //
localManager.argumentPostConfigure.get(0), localManager.argumentPostConfigure.get(0), //
localManager.argumentPostConfigure.get(1), localManager.argumentPostConfigure.get(1), //
localManager.argumentPostConfigure.get(2), localManager.argumentPostConfigure.get(2), //
localManager.argumentPostConfigure.get(3), localManager.argumentPostConfigure.get(3), //
localManager.argumentPostConfigure.get(4), localManager.argumentPostConfigure.get(4), //
localManager.argumentPostConfigure.get(5)); localManager.argumentPostConfigure.get(5));
break; break;
case 7: case 7:
exec.invoke(obj, exec.invoke(obj, //
localManager.argumentPostConfigure.get(0), localManager.argumentPostConfigure.get(0), //
localManager.argumentPostConfigure.get(1), localManager.argumentPostConfigure.get(1), //
localManager.argumentPostConfigure.get(2), localManager.argumentPostConfigure.get(2), //
localManager.argumentPostConfigure.get(3), localManager.argumentPostConfigure.get(3), //
localManager.argumentPostConfigure.get(4), localManager.argumentPostConfigure.get(4), //
localManager.argumentPostConfigure.get(5), localManager.argumentPostConfigure.get(5), //
localManager.argumentPostConfigure.get(6)); localManager.argumentPostConfigure.get(6));
break; break;
default: default:
@ -212,18 +213,19 @@ public class ArgumentManager {
} }
public void showHelp() { public List<String> getArgumentDetected() {
this.properties.displayHelp(); return this.argumentPostConfigure;
}
public boolean hasArgumentDetected() {
return this.argumentPostConfigure.size() != 0;
} }
public boolean hasDetectedAction() { public boolean hasDetectedAction() {
return this.actionDetected != null; return this.actionDetected != null;
} }
public boolean hasArgumentDetected() { public void showHelp() {
return this.argumentPostConfigure.size() != 0; this.properties.displayHelp();
}
public List<String> getArgumentDetected() {
return this.argumentPostConfigure;
} }
} }

View File

@ -48,7 +48,7 @@ public class Log {
public static void print(final String data) { public static void print(final String data) {
if (PRINT_PRINT) { if (PRINT_PRINT) {
Logger.print(LIB_NAME_DRAW, data); System.out.println(data);
} }
} }