mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 00:08:07 +02:00
profile: match on package name instead of regex
This commit is contained in:
parent
741a6bfad5
commit
d6f5da51d3
1 changed files with 12 additions and 1 deletions
|
@ -457,6 +457,7 @@ enum MatcherType
|
|||
{
|
||||
Regex,
|
||||
StorePath,
|
||||
Name,
|
||||
};
|
||||
|
||||
struct Matcher
|
||||
|
@ -489,6 +490,16 @@ Matcher createStorePathMatcher(const nix::StorePath & storePath)
|
|||
};
|
||||
}
|
||||
|
||||
Matcher createNameMatcher(const std::string & name) {
|
||||
return {
|
||||
.type = MatcherType::Name,
|
||||
.title = fmt("Package name '%s'", name),
|
||||
.matches = [name](const std::string &elementName, const ProfileElement & element) {
|
||||
return elementName == name;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class MixProfileElementMatchers : virtual Args, virtual StoreCommand
|
||||
{
|
||||
std::vector<Matcher> _matchers;
|
||||
|
@ -507,7 +518,7 @@ public:
|
|||
} else if (getStore()->isStorePath(arg)) {
|
||||
_matchers.push_back(createStorePathMatcher(getStore()->parseStorePath(arg)));
|
||||
} else {
|
||||
_matchers.push_back(createRegexMatcher(arg));
|
||||
_matchers.push_back(createNameMatcher(arg));
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
|
Loading…
Reference in a new issue