Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eclipse Projects
Eclipse ESCET (Supervisory Control Engineering Toolkit)
escet
Commits
17e70e53
Commit
17e70e53
authored
May 03, 2022
by
Dennis Hendriks
Browse files
#111
Somewhat more robust command line argument processing.
parent
b2aa7dcf
Pipeline
#3869
passed with stage
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
common/org.eclipse.escet.common.raildiagrams/src/org/eclipse/escet/common/raildiagrams/RailRoadDiagramGenerator.java
View file @
17e70e53
...
...
@@ -21,11 +21,9 @@ import java.nio.charset.StandardCharsets;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.function.Consumer
;
import
org.eclipse.escet.common.java.Assert
;
import
org.eclipse.escet.common.java.Strings
;
import
org.eclipse.escet.common.raildiagrams.config.Configuration
;
import
org.eclipse.escet.common.raildiagrams.output.DebugImageOutput
;
...
...
@@ -59,12 +57,24 @@ public class RailRoadDiagramGenerator {
* @throws IOException In case of an I/O error.
*/
public
static
void
main
(
String
[]
args
)
throws
IOException
{
Assert
.
check
(
args
.
length
==
3
||
args
.
length
==
4
,
Arrays
.
toString
(
args
));
// Process command line arguments.
if
(
args
.
length
!=
3
&&
args
.
length
!=
4
)
{
System
.
err
.
printf
(
"Expected 3 or 4 command line arguments, but got %d.%n"
,
args
.
length
);
System
.
exit
(
1
);
}
Path
inputPath
=
Paths
.
get
(
args
[
0
]);
Path
outputPath
=
Paths
.
get
(
args
[
1
]);
OutputFormat
outputFormat
=
OutputFormat
.
valueOf
(
Strings
.
makeUppercase
(
args
[
2
]).
replace
(
'-'
,
'_'
));
OutputFormat
outputFormat
;
try
{
outputFormat
=
OutputFormat
.
valueOf
(
Strings
.
makeUppercase
(
args
[
2
]).
replace
(
'-'
,
'_'
));
}
catch
(
IllegalArgumentException
e
)
{
System
.
err
.
printf
(
"Invalid output type: %s%n"
,
args
[
2
]);
System
.
exit
(
1
);
return
;
// Never reached.
}
Path
configPath
=
(
args
.
length
==
3
)
?
null
:
Paths
.
get
(
args
[
3
]);
// Generate railroad diagram image.
generate
(
inputPath
,
configPath
,
outputPath
,
outputFormat
,
null
,
System
.
err
::
println
);
}
...
...
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