mirror of
https://github.com/zaaarf/lillero-mapping-writer.git
synced 2024-11-22 15:44:53 +01:00
feat: -o flag
This commit is contained in:
parent
3e2f0a6bcf
commit
32ea510f10
1 changed files with 7 additions and 4 deletions
|
@ -23,7 +23,8 @@ public class MappingWriter {
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) throws IOException, ParseException {
|
public static void main(String[] args) throws IOException, ParseException {
|
||||||
Options options = new Options()
|
Options options = new Options()
|
||||||
.addOption("r", "reverse", false, "Writes down inverted mappings");
|
.addOption("r", "reverse", false, "Writes down inverted mappings")
|
||||||
|
.addOption("o", "overwrite", false, "Overwrites the file even if it exists");
|
||||||
DefaultParser parser = new DefaultParser();
|
DefaultParser parser = new DefaultParser();
|
||||||
CommandLine cmdLine = parser.parse(options, args);
|
CommandLine cmdLine = parser.parse(options, args);
|
||||||
args = cmdLine.getArgs();
|
args = cmdLine.getArgs();
|
||||||
|
@ -70,9 +71,11 @@ public class MappingWriter {
|
||||||
//now for the file
|
//now for the file
|
||||||
File targetFile = new File(args[2]);
|
File targetFile = new File(args[2]);
|
||||||
|
|
||||||
if(!targetFile.createNewFile()) {
|
if(!cmdLine.hasOption("overwrite") || !targetFile.exists()) {
|
||||||
System.err.println("File already exists!");
|
if(!targetFile.createNewFile()) {
|
||||||
return;
|
System.err.println("File already exists!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!targetFile.canWrite()) {
|
if(!targetFile.canWrite()) {
|
||||||
|
|
Loading…
Reference in a new issue