summaryrefslogtreecommitdiff
path: root/src/openscad.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/openscad.cc')
-rw-r--r--src/openscad.cc25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/openscad.cc b/src/openscad.cc
index 12e22ce..a5c56f6 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -254,17 +254,24 @@ int cmdline(const char *deps_output_file, const std::string &filename, Camera &c
AbstractNode *absolute_root_node;
CGAL_Nef_polyhedron root_N;
- handle_dep(filename.c_str());
-
- std::ifstream ifs(filename.c_str());
- if (!ifs.is_open()) {
- PRINTB("Can't open input file '%s'!\n", filename.c_str());
- return 1;
+ std::string text, parentpath;
+ if (filename != "-") {
+ handle_dep(filename);
+
+ std::ifstream ifs(filename.c_str());
+ if (!ifs.is_open()) {
+ PRINTB("Can't open input file '%s'!\n", filename.c_str());
+ return 1;
+ }
+ text = std::string((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
+ fs::path abspath = boosty::absolute(filename);
+ parentpath = boosty::stringy(abspath.parent_path());
+ }else{
+ text = std::string((std::istreambuf_iterator<char>(std::cin)), std::istreambuf_iterator<char>());
+ parentpath = boosty::stringy(original_path);
}
- std::string text((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
text += "\n" + commandline_commands;
- fs::path abspath = boosty::absolute(filename);
- std::string parentpath = boosty::stringy(abspath.parent_path());
+
root_module = parse(text.c_str(), parentpath.c_str(), false);
if (!root_module) {
PRINTB("Can't parse file '%s'!\n", filename.c_str());
contact: Jan Huwald // Impressum