mirror of
https://github.com/zaaarf/lillero-mapping-writer.git
synced 2024-11-14 05:29:22 +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 {
|
||||
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();
|
||||
CommandLine cmdLine = parser.parse(options, args);
|
||||
args = cmdLine.getArgs();
|
||||
|
@ -70,9 +71,11 @@ public class MappingWriter {
|
|||
//now for the file
|
||||
File targetFile = new File(args[2]);
|
||||
|
||||
if(!targetFile.createNewFile()) {
|
||||
System.err.println("File already exists!");
|
||||
return;
|
||||
if(!cmdLine.hasOption("overwrite") || !targetFile.exists()) {
|
||||
if(!targetFile.createNewFile()) {
|
||||
System.err.println("File already exists!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(!targetFile.canWrite()) {
|
||||
|
|
Loading…
Reference in a new issue