| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2020-08-25 17:04:23 +0200 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2020-08-25 17:04:23 +0200 | 
| commit | e620e366e5ffb90aa0ae321872e970c7de30b236 (patch) | |
| tree | 22e984093f76850ad70db9ec94fceb8fca43218a /src/json-export | |
| parent | 3a910e2df9bb71e0a1601e3be9367278bf6f897f (diff) | |
Adds invokation parameters.
Diffstat (limited to 'src/json-export')
| -rw-r--r-- | src/json-export/Makefile | 2 | ||||
| -rw-r--r-- | src/json-export/src/tonkadur/plugin/JSONExport.java | 44 | 
2 files changed, 44 insertions, 2 deletions
| diff --git a/src/json-export/Makefile b/src/json-export/Makefile index afe05e5..8654cc8 100644 --- a/src/json-export/Makefile +++ b/src/json-export/Makefile @@ -75,7 +75,7 @@ clean:  	rm -rf $(LIB_DIR)/$(STANDALONE)  # Pattern rules can be used to generate multiple target in a single action. -$(CLASSES): $(BIN_DIR)/%.class: $(SRC_DIR)/%.java $(BIN_DIR) +$(CLASSES): $(BIN_DIR)/%.class: $(SRC_DIR)/%.java $(BIN_DIR) $(JSON_SIMPLE_JAR) $(TONKADUR_CORE_JAR)  	$(JAVAC) -cp $(CLASSPATH) -d $(BIN_DIR) $<  %.jar: diff --git a/src/json-export/src/tonkadur/plugin/JSONExport.java b/src/json-export/src/tonkadur/plugin/JSONExport.java index 6d746f9..1e5a070 100644 --- a/src/json-export/src/tonkadur/plugin/JSONExport.java +++ b/src/json-export/src/tonkadur/plugin/JSONExport.java @@ -1,6 +1,10 @@  package tonkadur.plugin; +import java.util.Arrays; +import java.util.Iterator; +  import tonkadur.TonkadurPlugin; +import tonkadur.RuntimeParameters;  import tonkadur.wyrd.v1.lang.World; @@ -15,7 +19,39 @@ public class JSONExport extends TonkadurPlugin     public void initialize (final String[] args)     throws Throwable     { -      output_file = (args[0] + ".json"); +      final Iterator<String> args_it; + +      args_it = Arrays.stream(args).iterator(); + +      output_file = null; + +      while (args_it.hasNext()) +      { +         final String option = args_it.next(); + +         if (option.equals("-o") || option.equals("--output")) +         { +            if (!args_it.hasNext()) +            { +               throw +                  new Exception +                  ( +                     "Invalide usage. No arguments to " +                     + option +                     + " parameter" +                  ); +            } + +            output_file = args_it.next(); + +            break; +         } +      } + +      if (output_file == null) +      { +         output_file = (RuntimeParameters.get_input_file() + ".json"); +      }     }     @Override @@ -31,4 +67,10 @@ public class JSONExport extends TonkadurPlugin     {        Translator.toJSON(wyrd_world, output_file);     } + +   @Override +   public void print_options () +   { +      System.out.println(" -o|--output <file>\t\tOutput to <file>."); +   }  } | 


