[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.
*.pyc

View File

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

View File

@ -16,9 +16,13 @@ public class ArgumentManager {
private final PropertiesInterface properties;
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) {
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.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) {
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);
if (endParsing) {
this.argumentResidual.add(value);
@ -45,7 +46,7 @@ public class ArgumentManager {
if (value.startsWith("--")) {
String[] elements = value.split("=");
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 newValue = null;
if (!this.properties.existParameter(parameter)) {
@ -57,10 +58,10 @@ public class ArgumentManager {
Log.critical("Boolean parameter can not have parameters for '" + value + "'");
}
} 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)");
}
newValue = this.arguments.get(iii+1);
newValue = this.arguments.get(iii + 1);
if (newValue.startsWith("-")) {
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) {
if (iii==this.arguments.size()-1) {
if (iii == this.arguments.size() - 1) {
Log.critical("Missing parameters for '" + value + "' (no more arguments)");
}
newValue = this.arguments.get(iii+1);
newValue = this.arguments.get(iii + 1);
if (newValue.startsWith("-")) {
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);
} else {
Log.warning("find element ( ) : " + value);
if (this.properties.actions!= null && this.properties.actions.exist(value)) {
Log.verbose("find element ( ) : " + value);
if (this.properties.actions != null && this.properties.actions.exist(value)) {
// Find end of parsing ...
endParsing = true;
this.actionDetected = value;
@ -145,59 +146,59 @@ public class ArgumentManager {
Log.warning("Rejected executor, " + exec.getName() + " nbParameter=" + exec.getParameterCount() + " require=" + nbParameters);
continue;
}
Log.warning("find executor, " + exec.getName());
Log.verbose("find executor, " + exec.getName());
try {
switch(nbParameters) {
switch (nbParameters) {
case 0:
exec.invoke(obj);
break;
case 1:
exec.invoke(obj,
exec.invoke(obj, //
localManager.argumentPostConfigure.get(0));
break;
case 2:
exec.invoke(obj,
localManager.argumentPostConfigure.get(0),
exec.invoke(obj, //
localManager.argumentPostConfigure.get(0), //
localManager.argumentPostConfigure.get(1));
break;
case 3:
exec.invoke(obj,
localManager.argumentPostConfigure.get(0),
localManager.argumentPostConfigure.get(1),
exec.invoke(obj, //
localManager.argumentPostConfigure.get(0), //
localManager.argumentPostConfigure.get(1), //
localManager.argumentPostConfigure.get(2));
break;
case 4:
exec.invoke(obj,
localManager.argumentPostConfigure.get(0),
localManager.argumentPostConfigure.get(1),
localManager.argumentPostConfigure.get(2),
exec.invoke(obj, //
localManager.argumentPostConfigure.get(0), //
localManager.argumentPostConfigure.get(1), //
localManager.argumentPostConfigure.get(2), //
localManager.argumentPostConfigure.get(3));
break;
case 5:
exec.invoke(obj,
localManager.argumentPostConfigure.get(0),
localManager.argumentPostConfigure.get(1),
localManager.argumentPostConfigure.get(2),
localManager.argumentPostConfigure.get(3),
exec.invoke(obj, //
localManager.argumentPostConfigure.get(0), //
localManager.argumentPostConfigure.get(1), //
localManager.argumentPostConfigure.get(2), //
localManager.argumentPostConfigure.get(3), //
localManager.argumentPostConfigure.get(4));
break;
case 6:
exec.invoke(obj,
localManager.argumentPostConfigure.get(0),
localManager.argumentPostConfigure.get(1),
localManager.argumentPostConfigure.get(2),
localManager.argumentPostConfigure.get(3),
localManager.argumentPostConfigure.get(4),
exec.invoke(obj, //
localManager.argumentPostConfigure.get(0), //
localManager.argumentPostConfigure.get(1), //
localManager.argumentPostConfigure.get(2), //
localManager.argumentPostConfigure.get(3), //
localManager.argumentPostConfigure.get(4), //
localManager.argumentPostConfigure.get(5));
break;
case 7:
exec.invoke(obj,
localManager.argumentPostConfigure.get(0),
localManager.argumentPostConfigure.get(1),
localManager.argumentPostConfigure.get(2),
localManager.argumentPostConfigure.get(3),
localManager.argumentPostConfigure.get(4),
localManager.argumentPostConfigure.get(5),
exec.invoke(obj, //
localManager.argumentPostConfigure.get(0), //
localManager.argumentPostConfigure.get(1), //
localManager.argumentPostConfigure.get(2), //
localManager.argumentPostConfigure.get(3), //
localManager.argumentPostConfigure.get(4), //
localManager.argumentPostConfigure.get(5), //
localManager.argumentPostConfigure.get(6));
break;
default:
@ -212,18 +213,19 @@ public class ArgumentManager {
}
public void showHelp() {
this.properties.displayHelp();
public List<String> getArgumentDetected() {
return this.argumentPostConfigure;
}
public boolean hasArgumentDetected() {
return this.argumentPostConfigure.size() != 0;
}
public boolean hasDetectedAction() {
return this.actionDetected != null;
}
public boolean hasArgumentDetected() {
return this.argumentPostConfigure.size() != 0;
}
public List<String> getArgumentDetected() {
return this.argumentPostConfigure;
public void showHelp() {
this.properties.displayHelp();
}
}

View File

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