diff options
author | jaseg <git@jaseg.de> | 2021-01-27 00:49:31 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2021-01-27 00:49:31 +0100 |
commit | 5285b6dce8f0df37282b744ce625d4976b0f2541 (patch) | |
tree | 3e73522b83c9b83c8e3aeb49bb17bb7a61293796 /src/main.cpp | |
parent | 70d0021df14faa412d9a94d0e59bfcd4c7082a9d (diff) | |
download | gerbolyze-5285b6dce8f0df37282b744ce625d4976b0f2541.tar.gz gerbolyze-5285b6dce8f0df37282b744ce625d4976b0f2541.tar.bz2 gerbolyze-5285b6dce8f0df37282b744ce625d4976b0f2541.zip |
Add group id include/exclude matching
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index 773b1a4..889fe6a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,6 +38,13 @@ int main(int argc, char **argv) { {"flatten", {"--flatten"}, "Flatten output so it only consists of non-overlapping white polygons. This perform composition at the vector level. Potentially slow.", 0}, + {"only_groups", {"-g", "--only-groups"}, + "Comma-separated list of group IDs to export.", + 1}, + {"exclude_groups", {"-e", "--exclude-groups"}, + "Comma-separated list of group IDs to exclude from export. Takes precedence over --only-groups.", + 1}, + }}; @@ -143,7 +150,21 @@ int main(int argc, char **argv) { flattener = new Flattener(*sink); } - doc.render(flattener ? *flattener : *sink); + /* Because the C++ stdlib is bullshit */ + auto id_match = [](string in, vector<string> &out) { + stringstream ss(in); + while (getline(ss, out.emplace_back(), ',')) { + } + out.pop_back(); + }; + + ElementSelector sel; + if (args["only_groups"]) + id_match(args["only_groups"], sel.include); + if (args["exclude_groups"]) + id_match(args["exclude_groups"], sel.exclude); + + doc.render(flattener ? *flattener : *sink, &sel); return EXIT_SUCCESS; } |