snix/third_party/nix/src/libmain/common-args.cc
Vincent Ambo 838f86b0fd style(3p/nix): Remove 'using std::*' from types.hh
It is considered bad form to use things from includes in headers, as
these directives propagate to everywhere else and can make it
confusing.

types.hh (which is includes almost literally everywhere) had some of
these directives, which this commit removes.
2020-05-24 22:29:21 +01:00

42 lines
1 KiB
C++

#include "common-args.hh"
#include <glog/logging.h>
#include "globals.hh"
namespace nix {
MixCommonArgs::MixCommonArgs(const std::string& programName)
: programName(programName) {
mkFlag()
.longName("option")
.labels({"name", "value"})
.description("set a Nix configuration option (overriding nix.conf)")
.arity(2)
.handler([](std::vector<std::string> ss) {
try {
globalConfig.set(ss[0], ss[1]);
} catch (UsageError& e) {
LOG(WARNING) << e.what();
}
});
mkFlag()
.longName("max-jobs")
.shortName('j')
.label("jobs")
.description("maximum number of parallel builds")
.handler([=](const std::string& s) { settings.set("max-jobs", s); });
std::string cat = "config";
globalConfig.convertToArgs(*this, cat);
// Backward compatibility hack: nix-env already had a --system flag.
if (programName == "nix-env") {
longFlags.erase("system");
}
hiddenCategories.insert(cat);
}
} // namespace nix