Skip to content

Commit

Permalink
Fixed parameter bug
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-schnell committed Jan 24, 2022
1 parent 6cd0dd1 commit 8775fbe
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
12 changes: 6 additions & 6 deletions app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ https://github.com/fuinorg/code2svg/releases

Execute the shell script to start the conversion:
```
./code2svg.sh CONFIG_NAME FILE_OR_DIR_1 ... FILE_OR_DIR_N
./code2svg.sh (CONFIG_NAME) (TARGET_DIR) (FILE_OR_DIR_1) ... (FILE_OR_DIR_N)
```

Examples:
```
./code2svg.sh example/code-2-svg.xml example/Alpha3CountryCode-lf.ddd
./code2svg.sh example/code-2-svg.xml example/
./code2svg.sh example/code-2-svg.xml example example/Alpha3CountryCode-lf.ddd
./code2svg.sh example/code-2-svg.xml example example/
```

**Tip:** You can just execute the file ``./code2svg-example.sh`` without any arguments to run the above sample.
Expand All @@ -29,13 +29,13 @@ https://github.com/fuinorg/code2svg/releases

Execute the batch file to start the conversion:
```
code2svg.bat CONFIG_NAME FILE_OR_DIR_1 ... FILE_OR_DIR_N
code2svg.bat (CONFIG_NAME) (TARGET_DIR) (FILE_OR_DIR_1) ... (FILE_OR_DIR_N)
```

Examples:
```
code2svg.bat example/code-2-svg.xml example/Alpha3CountryCode-crlf.ddd
code2svg.bat example/code-2-svg.xml example/
code2svg.bat example/code-2-svg.xml example example/Alpha3CountryCode-crlf.ddd
code2svg.bat example/code-2-svg.xml example example/
```

**Tip:** You can just execute the file ``code2svg-example.bat`` without any arguments to run the above sample.
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/app/code2svg-example.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
java -classpath *;lib/* org.fuin.code2svg.app.Code2SvgApp example/code-2-svg.xml example/Alpha3CountryCode-crlf.ddd
java -classpath *;lib/* org.fuin.code2svg.app.Code2SvgApp example example/code-2-svg.xml example/Alpha3CountryCode-crlf.ddd
ECHO "Converted 'example/Alpha3CountryCode-crlf.ddd' to 'example/Alpha3CountryCode-crlf.ddd.svg'"
4 changes: 2 additions & 2 deletions app/src/main/app/code2svg-example.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
java -classpath *:lib/* org.fuin.code2svg.app.Code2SvgApp example/code-2-svg.xml example/Alpha3CountryCode-lf.ddd
echo "Converted 'example/Alpha3CountryCode-lf.ddd' to 'example/Alpha3CountryCode-lf.ddd.svg'"
java -classpath *:lib/* org.fuin.code2svg.app.Code2SvgApp example/code-2-svg.xml example example/Alpha3CountryCode-lf.ddd
echo "Converted 'example/Alpha3CountryCode-lf.ddd' to 'example/Alpha3CountryCode-lf.ddd.svg'"
17 changes: 9 additions & 8 deletions app/src/main/java/org/fuin/code2svg/app/Code2SvgApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.List;

import org.fuin.code2svg.core.Code2Svg;
import org.fuin.code2svg.core.Code2SvgConfig;
Expand All @@ -47,20 +48,20 @@ private static URL url(File file) {
}
}

private static void execute(final File configFile, final File targetDir, final String[] args) {
private static void execute(final File configFile, final File targetDir, final List<String> filenames) {

final String configXml = Utils4J.readAsString(url(configFile), "utf-8", 1024);
final Code2SvgConfig config = JaxbUtils.unmarshal(configXml, Code2SvgUtils.JAXB_CLASSES);

final Code2Svg converter = new Code2Svg();
for (int i = 1; i < args.length; i++) {
final File file = new File(args[i]);
filenames.forEach( filename -> {
final File file = new File(filename);
if (file.isDirectory()) {
converter.convertDir(config, file, targetDir);
} else {
converter.convertFile(config, file.getParentFile(), file, targetDir);
}
}
});

}

Expand All @@ -70,7 +71,7 @@ public static void main(String[] args) {
System.out.println("Required arguments: <config-path-and-name> <target dir> <source file or dir 1> ... <source file or dir N>");
System.exit(1);
}

try {
new LogbackStandalone().init(new File("code2svg"), new NewLogConfigFileParams("org.fuin.code2svg.app", "code2svg"));
LOG.info("Application running...");
Expand All @@ -79,13 +80,13 @@ public static void main(String[] args) {
Utils4J.checkValidFile(configFile);
final File targetDir = new File(args[1]);
Utils4J.checkValidDir(targetDir);
final String[] args2 = Arrays.copyOfRange(args, 2, args.length - 1);
final List<String> filenames = Arrays.asList(Arrays.copyOfRange(args, 2, args.length));

LOG.info("configFile={}", configFile);
LOG.info("targetDir={}", targetDir);
LOG.info("args2={}", Arrays.asList(args2));
LOG.info("filenames={}", filenames);

execute(configFile, targetDir, args2);
execute(configFile, targetDir, filenames);

System.exit(0);

Expand Down

0 comments on commit 8775fbe

Please sign in to comment.