mirror of
https://github.com/daveberrys/guh.git
synced 2026-11-29 00:26:46 +08:00
implement logs
This commit is contained in:
1 parent
772b4cade9
commit
f380c3c581
3 files changed
+24
-6
No files matched your search
+1
-3
@@ -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]",
|
||||
|
||||
@@ -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]})
|
||||
},
|
||||
}
|
||||
+3
-3
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user