github.com/erikjuhani/git-gong@v0.0.0-20220213141213-6b9fa82d4e7c/cmd/info.go (about) 1 package cmd 2 3 import ( 4 "github.com/erikjuhani/git-gong/gong" 5 "github.com/spf13/cobra" 6 ) 7 8 func init() { 9 rootCmd.AddCommand(infoCmd) 10 } 11 12 var infoCmd = &cobra.Command{ 13 Use: "info", 14 Short: "Show information of the current HEAD.", 15 Long: `Display difference between the index file and the current HEAD in short format. 16 Example status info output 17 Branch <branchname> 18 Commit <commitHash> 19 20 Changes (<number of file changes): 21 A <filename> 22 M <filename> 23 D <filename>`, 24 Run: func(cmd *cobra.Command, args []string) { 25 repo, err := gong.Open() 26 if err != nil { 27 cmd.PrintErr(err) 28 return 29 } 30 defer gong.Free(repo) 31 32 info, err := repo.Info() 33 if err != nil { 34 cmd.PrintErr(err) 35 return 36 } 37 38 cmd.Println(info) 39 }, 40 }