-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2481 from carapace-sh/git-hash-object
git: hash-object
- Loading branch information
Showing
2 changed files
with
45 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.