Skip to content

Commit

Permalink
config: allow overriding export dir via --exportDir
Browse files Browse the repository at this point in the history
This is useful for e.g. exporting to a versioned
(by date) dir.
  • Loading branch information
Cogitri authored and ximion committed Feb 2, 2021
1 parent 142b895 commit 4a2818d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ Application Options:
--verbose Show extra debugging information.
--force Force action.
-w|--workspace Define the workspace location.
-c|--config Use the given configuration file.";
-c|--config Use the given configuration file.
-e|--exportDir Directory to export data to.";

version (unittest) {
void main () {}
Expand Down Expand Up @@ -95,6 +96,7 @@ void main(string[] args)
bool showVersion;
bool forceAction;
string wdir;
string edir;
string configFname;

// parse command-line options
Expand All @@ -105,7 +107,8 @@ void main(string[] args)
"version", &showVersion,
"force", &forceAction,
"workspace|w", &wdir,
"config|c", &configFname);
"config|c", &configFname,
"exportDir|e", &edir);
} catch (Exception e) {
writeln ("Unable to parse parameters: ", e.msg);
exit (1);
Expand Down Expand Up @@ -140,7 +143,7 @@ void main(string[] args)
}

try {
conf.loadFromFile (configFname, wdir);
conf.loadFromFile (configFname, wdir, edir);
} catch (Exception e) {
writefln ("Unable to load configuration: %s", e.msg);
exit (4);
Expand Down
7 changes: 6 additions & 1 deletion src/asgen/config.d
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public:
return null;
}

void loadFromFile (string fname, string enforcedWorkspaceDir = null)
void loadFromFile (string fname, string enforcedWorkspaceDir = null, string enforcedExportDir = null)
{
// read the configuration JSON file
auto f = File (fname, "r");
Expand Down Expand Up @@ -306,6 +306,11 @@ public:

// set the default export directory locations, allow people to override them in the config
exportDir = buildPath (workspaceDir, "export");

// allow overriding the export location
if (!enforcedExportDir.empty)
exportDir = enforcedExportDir;

mediaExportDir = buildPath (exportDir, "media");
dataExportDir = buildPath (exportDir, "data");
hintsExportDir = buildPath (exportDir, "hints");
Expand Down

0 comments on commit 4a2818d

Please sign in to comment.