Author: cazfi
Date: Wed May  3 21:24:55 2017
New Revision: 35380

URL: http://svn.gna.org/viewcvs/freeciv?rev=35380&view=rev
Log:
Add --output DIRECTORY commandline parameter support to freeciv-ruleup

See hrm Feature #656672

Modified:
    trunk/tools/ruleup.c

Modified: trunk/tools/ruleup.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruleup.c?rev=35380&r1=35379&r2=35380&view=diff
==============================================================================
--- trunk/tools/ruleup.c        (original)
+++ trunk/tools/ruleup.c        Wed May  3 21:24:55 2017
@@ -39,6 +39,7 @@
 #include "rulesave.h"
 
 static char *rs_selected = NULL;
+static char *od_selected = NULL;
 
 /**************************************************************************
   Parse freeciv-ruleup commandline parameters.
@@ -59,6 +60,10 @@
                   /* TRANS: "ruleset" is exactly what user must type, do not 
translate. */
                   _("ruleset RULESET"),
                   _("Update RULESET"));
+      cmdhelp_add(help, "o",
+                 /* TRANS: "output" is exactly what user must type, do not 
translate. */
+                 _("output DIRECTORY"),
+                 _("Create directory DIRECTORY for output"));
 
       /* The function below prints a header and footer for the options.
        * Furthermore, the options are sorted. */
@@ -74,6 +79,13 @@
                    _("Multiple rulesets requested. Only one ruleset at time 
supported.\n"));
       } else {
         rs_selected = option;
+      }
+    } else if ((option = get_option_malloc("--output", argv, &i, argc, TRUE))) 
{
+      if (od_selected != NULL) {
+       fc_fprintf(stderr,
+                  _("Multiple output directories given.\n"));
+      } else {
+       od_selected = option;
       }
     } else {
       fc_fprintf(stderr, _("Unrecognized option: \"%s\"\n"), argv[i]);
@@ -134,7 +146,11 @@
 
     data.nationlist = game.server.ruledit.nationlist;
 
-    fc_snprintf(tgt_dir, sizeof(tgt_dir), "%s.ruleup", rs_selected);
+    if (od_selected != NULL) {
+      fc_strlcpy(tgt_dir, od_selected, sizeof(tgt_dir));
+    } else {
+      fc_snprintf(tgt_dir, sizeof(tgt_dir), "%s.ruleup", rs_selected);
+    }
 
     comments_load();
     save_ruleset(tgt_dir, rs_selected, &data);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to