mirror of
https://github.com/zaaarf/lillero-mapping-writer.git
synced 2024-11-22 16:14:58 +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,10 +71,12 @@ public class MappingWriter {
|
|||
//now for the file
|
||||
File targetFile = new File(args[2]);
|
||||
|
||||
if(!cmdLine.hasOption("overwrite") || !targetFile.exists()) {
|
||||
if(!targetFile.createNewFile()) {
|
||||
System.err.println("File already exists!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(!targetFile.canWrite()) {
|
||||
System.err.println("Failed to write to file: access denied.");
|
||||
|
|
Loading…
Reference in a new issue