[DEV] commit all with new insland
This commit is contained in:
parent
2935b4e474
commit
7dfde94a47
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
/__pycache__/
|
||||||
# Compiled python modules.
|
# Compiled python modules.
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|
||||||
|
2
out/eclipse/.gitignore
vendored
2
out/eclipse/.gitignore
vendored
@ -1 +1,3 @@
|
|||||||
|
|
||||||
|
/__pycache__/
|
||||||
/classes/
|
/classes/
|
||||||
|
@ -15,10 +15,14 @@ public class ArgumentManager {
|
|||||||
private String actionDetected = null;
|
private String actionDetected = null;
|
||||||
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,14 +34,11 @@ 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);
|
||||||
continue;
|
continue;
|
||||||
@ -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;
|
||||||
@ -117,7 +118,7 @@ public class ArgumentManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executeAction() {
|
public void executeAction() {
|
||||||
if (this.actionDetected == null) {
|
if (this.actionDetected == null) {
|
||||||
return;
|
return;
|
||||||
@ -145,60 +146,60 @@ 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:
|
||||||
Log.error("Does not manage more than 7 arguments");
|
Log.error("Does not manage more than 7 arguments");
|
||||||
@ -211,19 +212,20 @@ public class ArgumentManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showHelp() {
|
|
||||||
this.properties.displayHelp();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasDetectedAction() {
|
|
||||||
return this.actionDetected != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasArgumentDetected() {
|
|
||||||
return this.argumentPostConfigure.size() != 0;
|
|
||||||
}
|
|
||||||
public List<String> getArgumentDetected() {
|
public List<String> getArgumentDetected() {
|
||||||
return this.argumentPostConfigure;
|
return this.argumentPostConfigure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasArgumentDetected() {
|
||||||
|
return this.argumentPostConfigure.size() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasDetectedAction() {
|
||||||
|
return this.actionDetected != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showHelp() {
|
||||||
|
this.properties.displayHelp();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user