mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-27 08:16:14 +02:00
When completing flakerefs, only return directories
This commit is contained in:
parent
259ff74bde
commit
27d34ef770
3 changed files with 15 additions and 3 deletions
|
@ -220,17 +220,27 @@ Args::Flag Args::Flag::mkHashTypeFlag(std::string && longName, HashType * ht)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void completePath(size_t, std::string_view prefix)
|
static void completePath(std::string_view prefix, int flags)
|
||||||
{
|
{
|
||||||
pathCompletions = true;
|
pathCompletions = true;
|
||||||
glob_t globbuf;
|
glob_t globbuf;
|
||||||
if (glob((std::string(prefix) + "*").c_str(), GLOB_NOESCAPE | GLOB_TILDE, nullptr, &globbuf) == 0) {
|
if (glob((std::string(prefix) + "*").c_str(), GLOB_NOESCAPE | GLOB_TILDE | flags, nullptr, &globbuf) == 0) {
|
||||||
for (size_t i = 0; i < globbuf.gl_pathc; ++i)
|
for (size_t i = 0; i < globbuf.gl_pathc; ++i)
|
||||||
completions->insert(globbuf.gl_pathv[i]);
|
completions->insert(globbuf.gl_pathv[i]);
|
||||||
globfree(&globbuf);
|
globfree(&globbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void completePath(size_t, std::string_view prefix)
|
||||||
|
{
|
||||||
|
completePath(prefix, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void completeDir(size_t, std::string_view prefix)
|
||||||
|
{
|
||||||
|
completePath(prefix, GLOB_ONLYDIR);
|
||||||
|
}
|
||||||
|
|
||||||
Strings argvToStrings(int argc, char * * argv)
|
Strings argvToStrings(int argc, char * * argv)
|
||||||
{
|
{
|
||||||
Strings args;
|
Strings args;
|
||||||
|
|
|
@ -277,4 +277,6 @@ std::optional<std::string> needsCompletion(std::string_view s);
|
||||||
|
|
||||||
void completePath(size_t, std::string_view prefix);
|
void completePath(size_t, std::string_view prefix);
|
||||||
|
|
||||||
|
void completeDir(size_t, std::string_view prefix);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ Strings SourceExprCommand::getDefaultFlakeAttrPathPrefixes()
|
||||||
|
|
||||||
void SourceExprCommand::completeInstallable(std::string_view prefix)
|
void SourceExprCommand::completeInstallable(std::string_view prefix)
|
||||||
{
|
{
|
||||||
completePath(0, prefix);
|
completeDir(0, prefix);
|
||||||
|
|
||||||
if (file) return; // FIXME
|
if (file) return; // FIXME
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue