Skip to content

Commit

Permalink
Merge pull request #2408 from aftix/rm_nix_flags
Browse files Browse the repository at this point in the history
nix: updated completer flake-related flags
  • Loading branch information
rsteube authored Jun 11, 2024
2 parents 43a746f + 33bafb2 commit 5a3be21
Show file tree
Hide file tree
Showing 40 changed files with 207 additions and 24 deletions.
7 changes: 5 additions & 2 deletions completers/nix_completer/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ func init() {
rootCmd.AddCommand(buildCmd)

carapace.Gen(buildCmd).FlagCompletion(carapace.ActionMap{
"out-link": carapace.ActionFiles(),
"profile": carapace.ActionFiles(),
"inputs-from": nix.ActionFlakes(),
"out-link": carapace.ActionFiles(),
"output-lock-file": carapace.ActionFiles(),
"profile": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(buildCmd).PositionalCompletion(nix.ActionFlakes())
}
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ func init() {
addLoggingFlags(bundleCmd)

carapace.Gen(bundleCmd).FlagCompletion(carapace.ActionMap{
"bundler": nix.ActionFlakes(),
"bundler": nix.ActionFlakes(),
"inputs-from": nix.ActionFlakes(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(bundleCmd).PositionalCompletion(nix.ActionInstallables())
}
7 changes: 6 additions & 1 deletion completers/nix_completer/cmd/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ func init() {
addFlakeFlags(copyCmd)
addLoggingFlags(copyCmd)

// TODO flag completion
// TODO: --from/--to completion
carapace.Gen(copyCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})

carapace.Gen(copyCmd).PositionalAnyCompletion(nix.ActionInstallables())
}
4 changes: 0 additions & 4 deletions completers/nix_completer/cmd/derivation.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@ func init() {
carapace.Gen(derivationCmd).Standalone()

rootCmd.AddCommand(derivationCmd)

addEvaluationFlags(derivationCmd)
addFlakeFlags(derivationCmd)
addLoggingFlags(derivationCmd)
}
5 changes: 5 additions & 0 deletions completers/nix_completer/cmd/derivation_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@ func init() {
addFlakeFlags(derivation_showCmd)
addLoggingFlags(derivation_showCmd)

carapace.Gen(derivation_showCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(derivation_showCmd).PositionalAnyCompletion(nix.ActionInstallables())
}
8 changes: 6 additions & 2 deletions completers/nix_completer/cmd/develop.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ func init() {
carapace.ActionExecutables(),
carapace.ActionFiles(),
).ToA(),
"keep": os.ActionEnvironmentVariables(),
"unset": os.ActionEnvironmentVariables(),
"inputs-from": nix.ActionFlakes(),
"keep": os.ActionEnvironmentVariables(),
"output-lock-file": carapace.ActionFiles(),
"profile": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
"unset": os.ActionEnvironmentVariables(),
})
carapace.Gen(developCmd).PositionalCompletion(nix.ActionDevShells())
}
5 changes: 5 additions & 0 deletions completers/nix_completer/cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,10 @@ func init() {
addFlakeFlags(editCmd)
addLoggingFlags(editCmd)

carapace.Gen(editCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(editCmd).PositionalAnyCompletion(nix.ActionInstallables())
}
8 changes: 6 additions & 2 deletions completers/nix_completer/cmd/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ func init() {
addFlakeFlags(evalCmd)
addLoggingFlags(evalCmd)

// TODO flag completion

// TODO: --apply flag completion
carapace.Gen(evalCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(evalCmd).PositionalAnyCompletion(nix.ActionInstallables())
}
7 changes: 7 additions & 0 deletions completers/nix_completer/cmd/flake_archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/nix"
"github.com/spf13/cobra"
)

Expand All @@ -22,4 +23,10 @@ func init() {
addEvaluationFlags(flake_archiveCmd)
addFlakeFlags(flake_archiveCmd)
addLoggingFlags(flake_archiveCmd)

carapace.Gen(flake_archiveCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
}
5 changes: 5 additions & 0 deletions completers/nix_completer/cmd/flake_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ func init() {
addFlakeFlags(flake_checkCmd)
addLoggingFlags(flake_checkCmd)

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

flakeCmd.AddCommand(flake_checkCmd)
Expand Down
5 changes: 4 additions & 1 deletion completers/nix_completer/cmd/flake_clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ func init() {
addLoggingFlags(flake_cloneCmd)

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

Expand Down
1 change: 0 additions & 1 deletion completers/nix_completer/cmd/flake_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func init() {
flake_initCmd.Flags().StringP("template", "t", "default", "The template to use")

addEvaluationFlags(flake_initCmd)
addFlakeFlags(flake_initCmd)
addLoggingFlags(flake_initCmd)

carapace.Gen(flake_initCmd).FlagCompletion(carapace.ActionMap{
Expand Down
18 changes: 17 additions & 1 deletion completers/nix_completer/cmd/flake_lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,26 @@ var flake_lockCmd = &cobra.Command{
func init() {
carapace.Gen(flake_lockCmd).Standalone()

flake_lockCmd.Flags().Bool("commit-lock-file", false, "Commit changes to the flake's lock file")
flake_lockCmd.Flags().String("inputs-from", "", "Use the inputs of the specified flake as registry entries")
flake_lockCmd.Flags().Bool("no-registries", false, "Don't allow lookups in the flake registries")
flake_lockCmd.Flags().Bool("no-update-lock-file", false, "Do not allow any updates to the flake's lock file")
flake_lockCmd.Flags().String("output-lock-file", "", "Write the given lock file instead of flake.lock")
flake_lockCmd.Flags().String("override-input", "", "Override a specific flake input (e.g. dwarffs/nixpkgs)")
flake_lockCmd.Flags().Bool("recreate-lock-file", false, "Recreate the flake's lock file from scratch")
flake_lockCmd.Flags().String("reference-lock-file", "", "Read the given lock file instead of flake.lock")
flake_lockCmd.Flags().String("update-input", "", "Update a specific flake input (ignoring its previous entry in the lock file")

flake_lockCmd.Flag("override-input").Nargs = 2

addEvaluationFlags(flake_lockCmd)
addFlakeFlags(flake_lockCmd)
addLoggingFlags(flake_lockCmd)

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

flakeCmd.AddCommand(flake_lockCmd)
Expand Down
5 changes: 5 additions & 0 deletions completers/nix_completer/cmd/flake_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ func init() {
addFlakeFlags(flake_metadataCmd)
addLoggingFlags(flake_metadataCmd)

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

flakeCmd.AddCommand(flake_metadataCmd)
Expand Down
1 change: 0 additions & 1 deletion completers/nix_completer/cmd/flake_new.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func init() {
flake_newCmd.Flags().StringP("template", "t", "default", "The template to use")

addEvaluationFlags(flake_newCmd)
addFlakeFlags(flake_newCmd)
addLoggingFlags(flake_newCmd)

carapace.Gen(flake_newCmd).FlagCompletion(carapace.ActionMap{
Expand Down
5 changes: 5 additions & 0 deletions completers/nix_completer/cmd/flake_prefetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ func init() {
addFlakeFlags(flake_prefetchCmd)
addLoggingFlags(flake_prefetchCmd)

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

flakeCmd.AddCommand(flake_prefetchCmd)
Expand Down
5 changes: 5 additions & 0 deletions completers/nix_completer/cmd/flake_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ func init() {
addFlakeFlags(flake_showCmd)
addLoggingFlags(flake_showCmd)

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

flakeCmd.AddCommand(flake_showCmd)
Expand Down
15 changes: 14 additions & 1 deletion completers/nix_completer/cmd/flake_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,23 @@ var flake_updateCmd = &cobra.Command{
func init() {
carapace.Gen(flake_updateCmd).Standalone()

flake_updateCmd.Flags().Bool("commit-lock-file", false, "Commit changes to the flake's lock file")
flake_updateCmd.Flags().String("inputs-from", "", "Use the inputs of the specified flake as registry entries")
flake_updateCmd.Flags().Bool("no-registries", false, "Don't allow lookups in the flake registries")
flake_updateCmd.Flags().String("output-lock-file", "", "Write the given lock file instead of flake.lock")
flake_updateCmd.Flags().String("override-input", "", "Override a specific flake input (e.g. dwarffs/nixpkgs)")
flake_updateCmd.Flags().String("reference-lock-file", "", "Read the given lock file instead of flake.lock")

flake_updateCmd.Flag("override-input").Nargs = 2

addEvaluationFlags(flake_updateCmd)
addFlakeFlags(flake_updateCmd)
addLoggingFlags(flake_updateCmd)

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

flakeCmd.AddCommand(flake_updateCmd)
Expand Down
6 changes: 6 additions & 0 deletions completers/nix_completer/cmd/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/nix"
"github.com/spf13/cobra"
)

Expand All @@ -21,6 +22,11 @@ func init() {
addFlakeFlags(fmtCmd)
addLoggingFlags(fmtCmd)

carapace.Gen(fmtCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(fmtCmd).PositionalAnyCompletion(
carapace.ActionFiles(),
)
Expand Down
5 changes: 5 additions & 0 deletions completers/nix_completer/cmd/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,10 @@ func init() {
addFlakeFlags(logCmd)
addLoggingFlags(logCmd)

carapace.Gen(logCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(logCmd).PositionalAnyCompletion(nix.ActionInstallables())
}
5 changes: 5 additions & 0 deletions completers/nix_completer/cmd/pathInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@ func init() {
addFlakeFlags(pathInfoCmd)
addLoggingFlags(pathInfoCmd)

carapace.Gen(pathInfoCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(pathInfoCmd).PositionalAnyCompletion(nix.ActionInstallables())
}
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{
"profile": carapace.ActionFiles(),
"inputs-from": nix.ActionFlakes(),
"output-lock-file": carapace.ActionFiles(),
"profile": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(printDevEnvCmd).PositionalCompletion(nix.ActionInstallables())
}
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{
"profile": carapace.ActionDirectories(),
"inputs-from": nix.ActionFlakes(),
"output-lock-file": carapace.ActionFiles(),
"profile": carapace.ActionDirectories(),
"reference-lock-file": carapace.ActionFiles("lock"),
})

carapace.Gen(profile_installCmd).PositionalAnyCompletion(nix.ActionInstallables())
Expand Down
6 changes: 5 additions & 1 deletion completers/nix_completer/cmd/profile_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/nix"
"github.com/spf13/cobra"
)

Expand All @@ -22,6 +23,9 @@ func init() {
addLoggingFlags(profile_upgradeCmd)

carapace.Gen(profile_upgradeCmd).FlagCompletion(carapace.ActionMap{
"profile": carapace.ActionDirectories(),
"inputs-from": nix.ActionFlakes(),
"output-lock-file": carapace.ActionFiles(),
"profile": carapace.ActionDirectories(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
}
5 changes: 5 additions & 0 deletions completers/nix_completer/cmd/realisation_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,10 @@ func init() {
addFlakeFlags(realisation_infoCmd)
addLoggingFlags(realisation_infoCmd)

carapace.Gen(realisation_infoCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(realisation_infoCmd).PositionalAnyCompletion(nix.ActionInstallables())
}
5 changes: 5 additions & 0 deletions completers/nix_completer/cmd/repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@ func init() {
addInterpretationFlags(replCmd)
addLoggingFlags(replCmd)

carapace.Gen(replCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(replCmd).PositionalAnyCompletion(nix.ActionInstallables())
}
2 changes: 2 additions & 0 deletions completers/nix_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,10 @@ func addFlakeFlags(cmd *cobra.Command) {
cmd.Flags().Bool("no-registries", false, "Don't allow lookups in the flake registries")
cmd.Flags().Bool("no-update-lock-file", false, "Do not allow any updates to the flake's lock file")
cmd.Flags().Bool("no-write-lock-file", false, "Do not write the flake's newly generated lock file")
cmd.Flags().String("output-lock-file", "", "Write the given lock file instead of flake.lock")
cmd.Flags().String("override-input", "", "Override a specific flake input (e.g. dwarffs/nixpkgs)")
cmd.Flags().Bool("recreate-lock-file", false, "Recreate the flake's lock file from scratch")
cmd.Flags().String("reference-lock-file", "", "Read the given lock file instead of flake.lock")
cmd.Flags().String("update-input", "", "Update a specific flake input (ignoring its previous entry in the lock file")

cmd.Flag("override-input").Nargs = 2
Expand Down
5 changes: 5 additions & 0 deletions completers/nix_completer/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,10 @@ func init() {
addFlakeFlags(runCmd)
addLoggingFlags(runCmd)

carapace.Gen(runCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(runCmd).PositionalCompletion(nix.ActionInstallables())
}
5 changes: 5 additions & 0 deletions completers/nix_completer/cmd/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@ func init() {
addFlakeFlags(searchCmd)
addLoggingFlags(searchCmd)

carapace.Gen(searchCmd).FlagCompletion(carapace.ActionMap{
"inputs-from": nix.ActionFlakes(),
"output-lock-file": carapace.ActionFiles(),
"reference-lock-file": carapace.ActionFiles("lock"),
})
carapace.Gen(searchCmd).PositionalCompletion(nix.ActionInstallables())
}
Loading

0 comments on commit 5a3be21

Please sign in to comment.