Skip to content

Commit 8e6883a

Browse files
committed
Add wip diff cmd
1 parent 39475ef commit 8e6883a

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

cmd/dots/diff.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"io/ioutil"
6+
"strings"
7+
8+
"github.com/spf13/cobra"
9+
)
10+
11+
var diffCmd = cobra.Command{
12+
Use: "diff [git-diff options] [filter...]",
13+
Short: "Manage configuration of profiles and groups",
14+
RunE: func(cmd *cobra.Command, args []string) error {
15+
files := []string{}
16+
flags := []string{}
17+
18+
for _, arg := range args {
19+
if arg == "--" {
20+
continue
21+
}
22+
23+
if strings.HasPrefix(arg, "-") {
24+
flags = append(flags, arg)
25+
} else {
26+
files = append(files, arg)
27+
}
28+
}
29+
30+
sourceTmp, err := ioutil.TempDir("", "dots-source")
31+
if err != nil {
32+
return fmt.Errorf("Failed to create tmp directory: %s\n", err)
33+
}
34+
35+
activeTmp, err := ioutil.TempDir("", "dots-active")
36+
if err != nil {
37+
return fmt.Errorf("Failed to create tmp directory: %s\n", err)
38+
}
39+
40+
fmt.Println(sourceTmp, activeTmp)
41+
42+
exec := []string{"git", "diff", "--no-index"}
43+
exec = append(exec, flags...)
44+
exec = append(exec, "--", sourceTmp, activeTmp)
45+
46+
fmt.Println(exec)
47+
48+
return nil
49+
},
50+
51+
Args: cobra.ArbitraryArgs,
52+
DisableFlagsInUseLine: true,
53+
DisableFlagParsing: true,
54+
}

0 commit comments

Comments
 (0)