forked from OctaForge/OctaBuild
cleaner --change-directory
parent
48155c3df7
commit
04119652de
19
main.cc
19
main.cc
|
@ -601,10 +601,7 @@ int main(int argc, char **argv) {
|
||||||
ap.add_optional("-C", "--change-directory", 1)
|
ap.add_optional("-C", "--change-directory", 1)
|
||||||
.help("change to DIRECTORY before running")
|
.help("change to DIRECTORY before running")
|
||||||
.metavar("DIRECTORY")
|
.metavar("DIRECTORY")
|
||||||
.action([&curdir, &os](auto vals) {
|
.action(ostd::arg_store_str(curdir));
|
||||||
curdir = std::string{vals[0]};
|
|
||||||
fs::current_path(curdir);
|
|
||||||
});
|
|
||||||
|
|
||||||
std::string deffile = "obuild.cfg";
|
std::string deffile = "obuild.cfg";
|
||||||
ap.add_optional("-f", "--file", 1)
|
ap.add_optional("-f", "--file", 1)
|
||||||
|
@ -632,10 +629,6 @@ int main(int argc, char **argv) {
|
||||||
ostd::cerr.writefln("failed parsing arguments: %s", e.what());
|
ostd::cerr.writefln("failed parsing arguments: %s", e.what());
|
||||||
ap.print_help(ostd::cerr.iter());
|
ap.print_help(ostd::cerr.iter());
|
||||||
return 1;
|
return 1;
|
||||||
} catch (fs::filesystem_error const &e) {
|
|
||||||
return os.error(
|
|
||||||
1, "failed changing directory: %s (%s)", curdir, e.what()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (help.used()) {
|
if (help.used()) {
|
||||||
|
@ -647,6 +640,16 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
jobs = std::max(1, jobs);
|
jobs = std::max(1, jobs);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!curdir.empty()) {
|
||||||
|
fs::current_path(curdir);
|
||||||
|
}
|
||||||
|
} catch (fs::filesystem_error const &e) {
|
||||||
|
return os.error(
|
||||||
|
1, "failed changing directory: %s (%s)", curdir, e.what()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
os.new_ivar("numjobs", 4096, 1, jobs);
|
os.new_ivar("numjobs", 4096, 1, jobs);
|
||||||
|
|
||||||
ostd::thread_pool tpool;
|
ostd::thread_pool tpool;
|
||||||
|
|
Loading…
Reference in New Issue