Skip to content

Commit

Permalink
nix: re-add directory completion
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Dec 24, 2024
1 parent aaa850d commit 65c5351
Show file tree
Hide file tree
Showing 39 changed files with 193 additions and 51 deletions.
10 changes: 8 additions & 2 deletions completers/nix_completer/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,20 @@ func init() {
rootCmd.AddCommand(buildCmd)

carapace.Gen(buildCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"out-link": carapace.ActionFiles(),
"output-lock-file": carapace.ActionFiles(),
"profile": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})

carapace.Gen(buildCmd).PositionalCompletion(
nix.ActionFlakeRefs(),
carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakeRefs(),
).ToA(),
)
}
10 changes: 8 additions & 2 deletions completers/nix_completer/cmd/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ func init() {
addLoggingFlags(bundleCmd)

carapace.Gen(bundleCmd).FlagCompletion(carapace.ActionMap{
"bundler": nix.ActionFlakes(),
"inputs-from": nix.ActionFlakes(),
"bundler": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
Expand Down
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ func init() {

// TODO: --from/--to completion
carapace.Gen(copyCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
Expand Down
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/derivation_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ func init() {
addLoggingFlags(derivation_showCmd)

carapace.Gen(derivation_showCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
Expand Down
10 changes: 8 additions & 2 deletions completers/nix_completer/cmd/develop.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ func init() {
carapace.ActionExecutables(),
carapace.ActionFiles(),
).ToA(),
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"keep": os.ActionEnvironmentVariables(),
"output-lock-file": carapace.ActionFiles(),
"profile": carapace.ActionFiles(),
Expand All @@ -52,6 +55,9 @@ func init() {
})

carapace.Gen(developCmd).PositionalCompletion(
nix.ActionFlakeRefs(),
carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakeRefs(),
).ToA(),
)
}
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ func init() {
addLoggingFlags(editCmd)

carapace.Gen(editCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
Expand Down
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ func init() {

// TODO: --apply flag completion
carapace.Gen(evalCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
Expand Down
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/flake_archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ func init() {
addLoggingFlags(flake_archiveCmd)

carapace.Gen(flake_archiveCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
Expand Down
10 changes: 8 additions & 2 deletions completers/nix_completer/cmd/flake_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ func init() {
addLoggingFlags(flake_checkCmd)

carapace.Gen(flake_checkCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(flake_checkCmd).PositionalCompletion(nix.ActionFlakes())
carapace.Gen(flake_checkCmd).PositionalCompletion(carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA())

flakeCmd.AddCommand(flake_checkCmd)
}
12 changes: 9 additions & 3 deletions completers/nix_completer/cmd/flake_clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ func init() {
addLoggingFlags(flake_cloneCmd)

carapace.Gen(flake_cloneCmd).FlagCompletion(carapace.ActionMap{
"dest": carapace.ActionDirectories(),
"inputs-from": nix.ActionFlakes(),
"dest": carapace.ActionDirectories(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(flake_cloneCmd).PositionalCompletion(nix.ActionFlakes())
carapace.Gen(flake_cloneCmd).PositionalCompletion(carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA())

flakeCmd.AddCommand(flake_cloneCmd)
}
10 changes: 8 additions & 2 deletions completers/nix_completer/cmd/flake_lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@ func init() {
addLoggingFlags(flake_lockCmd)

carapace.Gen(flake_lockCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(flake_lockCmd).PositionalCompletion(nix.ActionFlakes())
carapace.Gen(flake_lockCmd).PositionalCompletion(carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA())

flakeCmd.AddCommand(flake_lockCmd)
}
10 changes: 8 additions & 2 deletions completers/nix_completer/cmd/flake_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ func init() {
addLoggingFlags(flake_metadataCmd)

carapace.Gen(flake_metadataCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(flake_metadataCmd).PositionalCompletion(nix.ActionFlakes())
carapace.Gen(flake_metadataCmd).PositionalCompletion(carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA())

flakeCmd.AddCommand(flake_metadataCmd)
}
10 changes: 8 additions & 2 deletions completers/nix_completer/cmd/flake_prefetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ func init() {
addLoggingFlags(flake_prefetchCmd)

carapace.Gen(flake_prefetchCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(flake_prefetchCmd).PositionalCompletion(nix.ActionFlakes())
carapace.Gen(flake_prefetchCmd).PositionalCompletion(carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA())

flakeCmd.AddCommand(flake_prefetchCmd)
}
10 changes: 8 additions & 2 deletions completers/nix_completer/cmd/flake_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ func init() {
addLoggingFlags(flake_showCmd)

carapace.Gen(flake_showCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(flake_showCmd).PositionalCompletion(nix.ActionFlakes())
carapace.Gen(flake_showCmd).PositionalCompletion(carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA())

flakeCmd.AddCommand(flake_showCmd)
}
10 changes: 8 additions & 2 deletions completers/nix_completer/cmd/flake_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ func init() {
addLoggingFlags(flake_updateCmd)

carapace.Gen(flake_updateCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(flake_updateCmd).PositionalCompletion(nix.ActionFlakes())
carapace.Gen(flake_updateCmd).PositionalCompletion(carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA())

flakeCmd.AddCommand(flake_updateCmd)
}
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ func init() {
addLoggingFlags(fmtCmd)

carapace.Gen(fmtCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
Expand Down
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ func init() {
addLoggingFlags(logCmd)

carapace.Gen(logCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
Expand Down
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/pathInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ func init() {
addLoggingFlags(pathInfoCmd)

carapace.Gen(pathInfoCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
Expand Down
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/printDevEnv.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ func init() {
addLoggingFlags(printDevEnvCmd)

carapace.Gen(printDevEnvCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"profile": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
Expand Down
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/profile_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ func init() {
addLoggingFlags(profile_installCmd)

carapace.Gen(profile_installCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"profile": carapace.ActionDirectories(),
"reference-lock-file": carapace.ActionFiles("lock"),
Expand Down
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/profile_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ func init() {
addLoggingFlags(profile_upgradeCmd)

carapace.Gen(profile_upgradeCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"profile": carapace.ActionDirectories(),
"reference-lock-file": carapace.ActionFiles("lock"),
Expand Down
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/realisation_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ func init() {
addLoggingFlags(realisation_infoCmd)

carapace.Gen(realisation_infoCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
Expand Down
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/registry_pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ func init() {
carapace.Gen(registry_pinCmd).FlagCompletion(carapace.ActionMap{
"registry": carapace.ActionFiles(),
})
carapace.Gen(registry_pinCmd).PositionalCompletion(nix.ActionFlakes())
carapace.Gen(registry_pinCmd).PositionalCompletion(carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA())
}
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/registry_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ func init() {
carapace.Gen(registry_removeCmd).FlagCompletion(carapace.ActionMap{
"registry": carapace.ActionFiles(),
})
carapace.Gen(registry_removeCmd).PositionalAnyCompletion(nix.ActionFlakes())
carapace.Gen(registry_removeCmd).PositionalAnyCompletion(carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA())
}
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ func init() {
addLoggingFlags(replCmd)

carapace.Gen(replCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
Expand Down
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ func init() {
addLoggingFlags(runCmd)

carapace.Gen(runCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"inputs-from": carapace.Batch(
carapace.ActionDirectories(),
nix.ActionFlakes(),
).ToA(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
Expand Down
Loading

0 comments on commit 65c5351

Please sign in to comment.