diff --git a/src/cmd/commit.go b/src/cmd/commit.go index 74a13a4..e276e7f 100644 --- a/src/cmd/commit.go +++ b/src/cmd/commit.go @@ -8,9 +8,7 @@ import ( "github.com/spf13/cobra" ) -func init() { - rootCmd.AddCommand(commitCmd) -} +func init() { rootCmd.AddCommand(commitCmd) } var commitCmd = &cobra.Command{ Use: "commit [files] [message] [description]", diff --git a/src/cmd/logs.go b/src/cmd/logs.go new file mode 100644 index 0000000..371fa42 --- /dev/null +++ b/src/cmd/logs.go @@ -0,0 +1,20 @@ +package cmd + +import ( + "github.com/daveberrys/guh/src/utils" + "github.com/spf13/cobra" +) + +func init() { rootCmd.AddCommand(logCmd) } + +var logCmd = &cobra.Command{ + Use: "logs [commits]", + Short: "Show commits logs.", + Args: cobra.MaximumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + if len(args) == 0 { + return utils.RunGitSequence(false, []string{"log"}) + } + return utils.RunGitSequence(false, []string{"log", "-"+args[0]}) + }, +} diff --git a/src/utils/git.go b/src/utils/git.go index 6c7326a..0aeb2aa 100644 --- a/src/utils/git.go +++ b/src/utils/git.go @@ -3,7 +3,7 @@ package utils import ( "bytes" "fmt" - "io" + // "io" "os" "os/exec" "strings" @@ -20,8 +20,8 @@ func RunGit(hideOutput bool, args ...string) (string, error) { gitCmd.Stdout = &stdout gitCmd.Stderr = &stderr } else { - gitCmd.Stdout = io.MultiWriter(os.Stdout, &stdout) - gitCmd.Stderr = io.MultiWriter(os.Stderr, &stderr) + gitCmd.Stdout = os.Stdout + gitCmd.Stderr = os.Stderr } err := gitCmd.Run()