Skip to content

Commit

Permalink
Add wip diff cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed Jul 3, 2018
1 parent 39475ef commit 8e6883a
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions cmd/dots/diff.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package main

import (
"fmt"
"io/ioutil"
"strings"

"github.com/spf13/cobra"
)

var diffCmd = cobra.Command{
Use: "diff [git-diff options] [filter...]",
Short: "Manage configuration of profiles and groups",
RunE: func(cmd *cobra.Command, args []string) error {
files := []string{}
flags := []string{}

for _, arg := range args {
if arg == "--" {
continue
}

if strings.HasPrefix(arg, "-") {
flags = append(flags, arg)
} else {
files = append(files, arg)
}
}

sourceTmp, err := ioutil.TempDir("", "dots-source")
if err != nil {
return fmt.Errorf("Failed to create tmp directory: %s\n", err)
}

activeTmp, err := ioutil.TempDir("", "dots-active")
if err != nil {
return fmt.Errorf("Failed to create tmp directory: %s\n", err)
}

fmt.Println(sourceTmp, activeTmp)

exec := []string{"git", "diff", "--no-index"}
exec = append(exec, flags...)
exec = append(exec, "--", sourceTmp, activeTmp)

fmt.Println(exec)

return nil
},

Args: cobra.ArbitraryArgs,
DisableFlagsInUseLine: true,
DisableFlagParsing: true,
}

0 comments on commit 8e6883a

Please sign in to comment.