Merge "libutil: fix args assert being thrown on Darwin in nix-eval-jobs" into main
This commit is contained in:
commit
a75d7a5777
3 changed files with 12 additions and 1 deletions
|
@ -64,7 +64,7 @@ RootArgs & Args::getRoot()
|
|||
while (p->parent)
|
||||
p = p->parent;
|
||||
|
||||
auto * res = dynamic_cast<RootArgs *>(p);
|
||||
auto res = p->asRootArgs();
|
||||
assert(res);
|
||||
return *res;
|
||||
}
|
||||
|
|
|
@ -244,6 +244,13 @@ protected:
|
|||
*/
|
||||
virtual void initialFlagsProcessed() {}
|
||||
|
||||
/**
|
||||
* Returns this Args as a RootArgs if it is one, or \ref std::nullopt otherwise.
|
||||
*/
|
||||
virtual std::optional<std::reference_wrapper<RootArgs>> asRootArgs() {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
void addFlag(Flag && flag);
|
||||
|
|
|
@ -65,6 +65,10 @@ protected:
|
|||
*/
|
||||
std::set<ExperimentalFeature> flagExperimentalFeatures;
|
||||
|
||||
virtual std::optional<std::reference_wrapper<RootArgs>> asRootArgs() override {
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::optional<std::string> needsCompletion(std::string_view s);
|
||||
|
|
Loading…
Reference in a new issue