Skip to content

Commit

Permalink
Merge pull request #2481 from carapace-sh/git-hash-object
Browse files Browse the repository at this point in the history
git: hash-object
  • Loading branch information
rsteube authored Aug 15, 2024
2 parents 32bbc75 + 05d8b45 commit 2551619
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 25 deletions.
45 changes: 45 additions & 0 deletions completers/git_completer/cmd/hashObject.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)

var hashObjectCmd = &cobra.Command{
Use: "hash-object",
Short: "Compute object ID and optionally creates a blob from a file",
Run: func(cmd *cobra.Command, args []string) {},
GroupID: groups[group_low_level_manipulator].ID,
}

func init() {
carapace.Gen(hashObjectCmd).Standalone()

hashObjectCmd.Flags().Bool("literally", false, "Allow --stdin to hash any garbage into a loose object")
hashObjectCmd.Flags().Bool("no-filters", false, "Hash the contents as is")
hashObjectCmd.Flags().String("path", "", "Hash object as if it were located at the given path")
hashObjectCmd.Flags().Bool("stdin", false, "Read the object from standard input instead of from a file")
hashObjectCmd.Flags().Bool("stdin-paths", false, "Read file names from the standard input")
hashObjectCmd.Flags().StringS("t", "t", "", "Specify the type of object to be created")
hashObjectCmd.Flags().BoolS("w", "w", false, "Actually write the object into the object database")
rootCmd.AddCommand(hashObjectCmd)

carapace.Gen(hashObjectCmd).FlagCompletion(carapace.ActionMap{
"path": carapace.ActionFiles(),
"t": carapace.ActionValues("commit", "tree", "blob", "tag"),
})

carapace.Gen(hashObjectCmd).PositionalAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if hashObjectCmd.Flag("stdin").Changed ||
hashObjectCmd.Flag("stdin-paths").Changed {
return carapace.ActionValues()
}
return carapace.ActionFiles()
}),
)

carapace.Gen(hashObjectCmd).DashAnyCompletion(
carapace.ActionPositional(hashObjectCmd),
)
}
25 changes: 0 additions & 25 deletions completers/git_completer/cmd/hash_object_generated.go

This file was deleted.

0 comments on commit 2551619

Please sign in to comment.