Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
845a15a9
Commit
845a15a9
authored
Nov 15, 2019
by
Stefan Schuhbaeck
Browse files
add better help text to utils command of vader-console
parent
e2677bf3
Pipeline
#177904
canceled with stages
in 27 minutes and 41 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
845a15a9
...
...
@@ -26,7 +26,7 @@
are possible with a fixed height of 5m.
-
vadere-console
`utils`
subCommand:
*
A miscellaneous collector of simple function operating on a single scenario file.
*
-f (input [required])
*
-f (input
file or directory depending on method m
[required])
*
-o (ouput file or directory depending on method m [optional])
*
-m (name of method.) See subparser help for allowed functions.
*
currently implementd:
...
...
VadereSimulator/src/org/vadere/simulator/entrypoints/cmd/VadereConsole.java
View file @
845a15a9
...
...
@@ -198,17 +198,17 @@ public class VadereConsole {
.
help
(
"Run utility functions."
)
.
setDefault
(
"func"
,
utilsSubCommand
);
misc
.
addArgument
(
"-
-scenario-file"
,
"-f
"
)
misc
.
addArgument
(
"-
i
"
)
.
required
(
true
)
.
type
(
String
.
class
)
.
dest
(
"
scenario-file
"
)
.
help
(
"
Scenario to work with
."
);
.
dest
(
"
input
"
)
.
help
(
"
A input file or directory depending on called method
."
);
misc
.
addArgument
(
"--output"
,
"-o"
)
misc
.
addArgument
(
"-o"
)
.
required
(
false
)
.
type
(
String
.
class
)
.
dest
(
"output"
)
.
help
(
"A output file or
folder
depending on called method."
);
.
help
(
"A output file or
directory
depending on called method."
);
String
[]
utilMethods
=
utilsSubCommand
.
methodsString
();
...
...
@@ -217,7 +217,7 @@ public class VadereConsole {
.
type
(
String
.
class
)
.
choices
(
utilMethods
)
.
dest
(
"method"
)
.
help
(
"Method name to call."
);
.
help
(
"Method name to call."
+
utilsSubCommand
.
methodHelp
()
);
}
}
VadereSimulator/src/org/vadere/simulator/entrypoints/cmd/commands/UtilsSubCommand.java
View file @
845a15a9
...
...
@@ -3,6 +3,7 @@ package org.vadere.simulator.entrypoints.cmd.commands;
import
net.sourceforge.argparse4j.inf.ArgumentParser
;
import
net.sourceforge.argparse4j.inf.Namespace
;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.vadere.simulator.entrypoints.ScenarioFactory
;
import
org.vadere.simulator.entrypoints.cmd.SubCommandRunner
;
import
org.vadere.simulator.models.potential.fields.IPotentialField
;
...
...
@@ -28,13 +29,13 @@ public class UtilsSubCommand implements SubCommandRunner {
private
final
static
Logger
logger
=
Logger
.
getLogger
(
UtilsSubCommand
.
class
);
private
HashMap
<
String
,
SubCommandRunner
>
methods
;
private
HashMap
<
String
,
Pair
<
String
,
SubCommandRunner
>
>
methods
;
public
UtilsSubCommand
()
{
methods
=
new
HashMap
<>();
methods
.
put
(
"getHash"
,
this
::
getHash
);
methods
.
put
(
"binCache"
,
this
::
calculateBinCache
);
methods
.
put
(
"txtCache"
,
this
::
calculateTextCache
);
methods
.
put
(
"getHash"
,
Pair
.
of
(
"[-i: file, -o: ignored]"
,
this
::
getHash
)
)
;
methods
.
put
(
"binCache"
,
Pair
.
of
(
"[-i: file, -o: directory]"
,
this
::
calculateBinCache
)
)
;
methods
.
put
(
"txtCache"
,
Pair
.
of
(
"[-i: file, -o: directory]"
,
this
::
calculateTextCache
)
)
;
}
...
...
@@ -45,6 +46,12 @@ public class UtilsSubCommand implements SubCommandRunner {
return
ret
;
}
public
String
methodHelp
(){
StringBuilder
sb
=
new
StringBuilder
();
methods
.
forEach
((
key
,
value
)
->
sb
.
append
(
"\n --> "
).
append
(
key
).
append
(
":"
).
append
(
value
.
getLeft
()));
return
sb
.
toString
();
}
private
Scenario
createScenario
(
String
path
)
throws
IOException
{
Scenario
scenario
=
null
;
try
{
...
...
@@ -61,7 +68,7 @@ public class UtilsSubCommand implements SubCommandRunner {
public
void
run
(
Namespace
ns
,
ArgumentParser
parser
)
throws
Exception
{
String
m
=
ns
.
get
(
"method"
);
SubCommandRunner
runner
=
methods
.
get
(
m
);
SubCommandRunner
runner
=
methods
.
get
(
m
)
.
getRight
()
;
if
(
runner
!=
null
){
runner
.
run
(
ns
,
parser
);
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment