-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
192f31a
commit a5d56ab
Showing
8 changed files
with
287 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package color | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
const ( | ||
Reset int = iota | ||
Bold | ||
Faint | ||
Italic | ||
Underline | ||
BlinkSlow | ||
BlinkRapid | ||
ReverseVideo | ||
Concealed | ||
CrossedOut | ||
) | ||
|
||
const ( | ||
FgBlack int = iota + 30 | ||
FgRed | ||
FgGreen | ||
FgYellow | ||
FgBlue | ||
FgMagenta | ||
FgCyan | ||
FgWhite | ||
) | ||
|
||
const ( | ||
Escape = "\x1b" | ||
) | ||
|
||
|
||
func Color(a int, msg string) string { | ||
return fmt.Sprintf("%s[%dm%s%s[%dm", Escape, a, msg, Escape, Reset) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"time" | ||
|
||
"github.com/nousefreak/projecthelper/internal/pkg/color" | ||
"github.com/nousefreak/projecthelper/internal/pkg/config" | ||
"github.com/nousefreak/projecthelper/internal/pkg/repo" | ||
"github.com/nousefreak/projecthelper/internal/pkg/wdid" | ||
"github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
"golang.org/x/term" | ||
) | ||
|
||
func getWDIDCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "wdid", | ||
Short: "wdid", | ||
Long: `wdid`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
|
||
amount := "1" | ||
unit := "day" | ||
|
||
if len(args) >= 1 { | ||
amount = args[0] | ||
} | ||
if len(args) >= 2 { | ||
unit = args[1] | ||
} | ||
|
||
window := fmt.Sprintf("%s %s ago", amount, unit) | ||
|
||
repoPaths, err := repo.GetRepoPaths(config.GetBaseDir()) | ||
if err != nil { | ||
logrus.Fatal(err) | ||
} | ||
|
||
logrus.Infof("Looking for your commits in %d repos since %s", len(repoPaths), window) | ||
reports, err := wdid.GetWDIDReport(window, repoPaths) | ||
if err != nil { | ||
logrus.Fatal(err) | ||
} | ||
|
||
width, _, _ := term.GetSize(0) | ||
out := os.Stderr | ||
for name, group := range reports { | ||
fmt.Fprintln(out, "") | ||
fmt.Fprintf(out, "%s\n", color.Color(color.FgGreen, name)) | ||
for _, r := range group { | ||
t := time.Unix(r.Timestamp(), 0) | ||
fmt.Fprintf(out, " - %-*s %s\n", width-22, r.ChangeLine(), color.Color(color.FgBlue, t.Format("2006-01-02 15:04"))) | ||
} | ||
} | ||
|
||
}, | ||
} | ||
return cmd | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.