aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-05-10 21:35:07 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-05-10 21:35:07 +0200
commite0c19ee620c53b52ca7cf69c19d414d782338be1 (patch)
treea28571713bc2558e09798d2f4bdc2d0220802649 /src/nix
parent91ddee6bf045b1c6144d14233abdb96127186ec3 (diff)
Add completion for paths
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/build.cc1
-rw-r--r--src/nix/cat.cc4
-rw-r--r--src/nix/command.cc1
-rw-r--r--src/nix/hash.cc2
-rw-r--r--src/nix/installables.cc3
-rw-r--r--src/nix/ls.cc4
-rw-r--r--src/nix/main.cc5
-rw-r--r--src/nix/repl.cc2
-rw-r--r--src/nix/run.cc2
-rw-r--r--src/nix/sigs.cc3
10 files changed, 16 insertions, 11 deletions
diff --git a/src/nix/build.cc b/src/nix/build.cc
index 83d47acd4..474337208 100644
--- a/src/nix/build.cc
+++ b/src/nix/build.cc
@@ -18,6 +18,7 @@ struct CmdBuild : InstallablesCommand, MixDryRun, MixProfile
.description = "path of the symlink to the build result",
.labels = {"path"},
.handler = {&outLink},
+ .completer = completePath
});
addFlag({
diff --git a/src/nix/cat.cc b/src/nix/cat.cc
index fd91f2036..eeee1e529 100644
--- a/src/nix/cat.cc
+++ b/src/nix/cat.cc
@@ -25,7 +25,7 @@ struct CmdCatStore : StoreCommand, MixCat
{
CmdCatStore()
{
- expectArg("path", &path);
+ expectPathArg("path", &path);
}
std::string description() override
@@ -47,7 +47,7 @@ struct CmdCatNar : StoreCommand, MixCat
CmdCatNar()
{
- expectArg("nar", &narPath);
+ expectPathArg("nar", &narPath);
expectArg("path", &path);
}
diff --git a/src/nix/command.cc b/src/nix/command.cc
index 71b027719..803a36e84 100644
--- a/src/nix/command.cc
+++ b/src/nix/command.cc
@@ -108,6 +108,7 @@ MixProfile::MixProfile()
.description = "profile to update",
.labels = {"path"},
.handler = {&profile},
+ .completer = completePath
});
}
diff --git a/src/nix/hash.cc b/src/nix/hash.cc
index 366314227..0f460c668 100644
--- a/src/nix/hash.cc
+++ b/src/nix/hash.cc
@@ -31,7 +31,7 @@ struct CmdHash : Command
.labels({"modulus"})
.dest(&modulus);
#endif
- expectArgs("paths", &paths);
+ expectPathArgs("paths", &paths);
}
std::string description() override
diff --git a/src/nix/installables.cc b/src/nix/installables.cc
index 57060e9b1..c144a7e70 100644
--- a/src/nix/installables.cc
+++ b/src/nix/installables.cc
@@ -77,7 +77,8 @@ SourceExprCommand::SourceExprCommand()
.shortName = 'f',
.description = "evaluate FILE rather than the default",
.labels = {"file"},
- .handler = {&file}
+ .handler = {&file},
+ .completer = completePath
});
addFlag({
diff --git a/src/nix/ls.cc b/src/nix/ls.cc
index b9716a6a1..aac082422 100644
--- a/src/nix/ls.cc
+++ b/src/nix/ls.cc
@@ -85,7 +85,7 @@ struct CmdLsStore : StoreCommand, MixLs
{
CmdLsStore()
{
- expectArg("path", &path);
+ expectPathArg("path", &path);
}
Examples examples() override
@@ -117,7 +117,7 @@ struct CmdLsNar : Command, MixLs
CmdLsNar()
{
- expectArg("nar", &narPath);
+ expectPathArg("nar", &narPath);
expectArg("path", &path);
}
diff --git a/src/nix/main.cc b/src/nix/main.cc
index c491bc264..fffdeab90 100644
--- a/src/nix/main.cc
+++ b/src/nix/main.cc
@@ -68,7 +68,7 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
addFlag({
.longName = "help",
.description = "show usage information",
- .handler = {[&]() { showHelpAndExit(); }},
+ .handler = {[&]() { if (!completions) showHelpAndExit(); }},
});
addFlag({
@@ -96,7 +96,7 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
addFlag({
.longName = "version",
.description = "show version information",
- .handler = {[&]() { printVersion(programName); }},
+ .handler = {[&]() { if (!completions) printVersion(programName); }},
});
addFlag({
@@ -169,6 +169,7 @@ void mainWrapped(int argc, char * * argv)
Finally printCompletions([&]()
{
if (completions) {
+ std::cout << (pathCompletions ? "filenames\n" : "no-filenames\n");
for (auto & s : *completions)
std::cout << s << "\n";
}
diff --git a/src/nix/repl.cc b/src/nix/repl.cc
index 0a6a7ab19..2e7b14d08 100644
--- a/src/nix/repl.cc
+++ b/src/nix/repl.cc
@@ -767,7 +767,7 @@ struct CmdRepl : StoreCommand, MixEvalArgs
CmdRepl()
{
- expectArgs("files", &files);
+ expectPathArgs("files", &files);
}
std::string description() override
diff --git a/src/nix/run.cc b/src/nix/run.cc
index 3e2c8b4f3..3701ffe3d 100644
--- a/src/nix/run.cc
+++ b/src/nix/run.cc
@@ -149,7 +149,7 @@ struct CmdRun : InstallableCommand, RunCommon
CmdRun()
{
- expectArgs("args", &args);
+ expectPathArgs("args", &args);
}
std::string description() override
diff --git a/src/nix/sigs.cc b/src/nix/sigs.cc
index 6c9b9a792..7821a5432 100644
--- a/src/nix/sigs.cc
+++ b/src/nix/sigs.cc
@@ -105,7 +105,8 @@ struct CmdSignPaths : StorePathsCommand
.shortName = 'k',
.description = "file containing the secret signing key",
.labels = {"file"},
- .handler = {&secretKeyFile}
+ .handler = {&secretKeyFile},
+ .completer = completePath
});
}