diff --git a/completers/git_completer/cmd/sendPack.go b/completers/git_completer/cmd/sendPack.go new file mode 100644 index 0000000000..148f7b5401 --- /dev/null +++ b/completers/git_completer/cmd/sendPack.go @@ -0,0 +1,60 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/pkg/actions/net" + "github.com/carapace-sh/carapace-bin/pkg/actions/tools/git" + "github.com/carapace-sh/carapace-bridge/pkg/actions/bridge" + "github.com/carapace-sh/carapace/pkg/style" + "github.com/spf13/cobra" +) + +var sendPackCmd = &cobra.Command{ + Use: "send-pack", + Short: "Push objects over Git protocol to another repository", + Run: func(cmd *cobra.Command, args []string) {}, + GroupID: groups[group_low_level_synching].ID, +} + +func init() { + carapace.Gen(sendPackCmd).Standalone() + + sendPackCmd.Flags().Bool("all", false, "update all heads that locally exist") + sendPackCmd.Flags().Bool("atomic", false, "use an atomic transaction for updating the refs") + sendPackCmd.Flags().Bool("dry-run", false, "do everything except actually send the updates") + sendPackCmd.Flags().String("exec", "", "same as --receive-pack=") + sendPackCmd.Flags().Bool("force", false, "disable ancestor check") + sendPackCmd.Flags().Bool("no-signed", false, "do not GPG-sign the push request") + sendPackCmd.Flags().String("push-option", "", "pass the specified string as a push option") + sendPackCmd.Flags().String("receive-pack", "", "path to the git-receive-pack program on the remote end") + sendPackCmd.Flags().String("signed", "", "GPG-sign the push request") + sendPackCmd.Flags().Bool("stdin", false, "take the list of refs from stdin, one per line") + sendPackCmd.Flags().Bool("thin", false, "send a \"thin\" pack") + sendPackCmd.Flags().Bool("verbose", false, "run verbosely") + rootCmd.AddCommand(sendPackCmd) + + carapace.Gen(sendPackCmd).FlagCompletion(carapace.ActionMap{ + "push-option": bridge.ActionCarapaceBin("git", "push").Split(), + "signed": carapace.ActionValues("true", "false", "if-asked").StyleF(style.ForKeyword), + }) + + carapace.Gen(sendPackCmd).PositionalCompletion( + carapace.ActionMultiPartsN(":", 2, func(c carapace.Context) carapace.Action { + switch len(c.Parts) { + case 0: + return net.ActionHosts().Suffix(":") + default: + return carapace.ActionValues() + } + }), + ) + + carapace.Gen(sendPackCmd).PositionalAnyCompletion( + carapace.ActionCallback(func(c carapace.Context) carapace.Action { + if sendPackCmd.Flag("all").Changed { + return carapace.ActionValues() + } + return git.ActionRefs(git.RefOption{}.Default()).FilterArgs().Shift(1) + }), + ) +} diff --git a/completers/git_completer/cmd/send_pack_generated.go b/completers/git_completer/cmd/send_pack_generated.go deleted file mode 100644 index 21127b9da0..0000000000 --- a/completers/git_completer/cmd/send_pack_generated.go +++ /dev/null @@ -1,36 +0,0 @@ -package cmd - -import ( - "github.com/carapace-sh/carapace" - "github.com/spf13/cobra" -) - -var send_packCmd = &cobra.Command{ - Use: "send-pack", - Short: "Push objects over Git protocol to another repository", - Run: func(cmd *cobra.Command, args []string) {}, - GroupID: groups[group_low_level_synching].ID, -} - -func init() { - carapace.Gen(send_packCmd).Standalone() - send_packCmd.Flags().Bool("all", false, "push all refs") - send_packCmd.Flags().Bool("atomic", false, "request atomic transaction on remote side") - send_packCmd.Flags().BoolP("dry-run", "n", false, "dry run") - send_packCmd.Flags().String("exec", "", "receive pack program") - send_packCmd.Flags().BoolP("force", "f", false, "force updates") - send_packCmd.Flags().String("force-with-lease", "", "require old value of ref to be at this value") - send_packCmd.Flags().Bool("helper-status", false, "print status from remote helper") - send_packCmd.Flags().Bool("mirror", false, "mirror all refs") - send_packCmd.Flags().Bool("progress", false, "force progress reporting") - send_packCmd.Flags().String("push-option", "", "option to transmit") - send_packCmd.Flags().BoolP("quiet", "q", false, "be more quiet") - send_packCmd.Flags().String("receive-pack", "", "receive pack program") - send_packCmd.Flags().String("remote", "", "remote name") - send_packCmd.Flags().String("signed", "", "GPG sign the push") - send_packCmd.Flags().Bool("stateless-rpc", false, "use stateless RPC protocol") - send_packCmd.Flags().Bool("stdin", false, "read refs from stdin") - send_packCmd.Flags().Bool("thin", false, "use thin pack") - send_packCmd.Flags().BoolP("verbose", "v", false, "be more verbose") - rootCmd.AddCommand(send_packCmd) -}