Skip to content

Commit

Permalink
Merge pull request #31 from knbr13/path-prompt-to-optional-flag
Browse files Browse the repository at this point in the history
Path prompt to optional flag
  • Loading branch information
knbr13 authored Jun 5, 2024
2 parents e4bd8a9 + 388eee8 commit 3c6fb29
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 77 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ By default, the tool displays commits from the last 6 months, but you can config
> gitcs -since "2023-10-24" -until "2024-01-15"
```

By default, the tool displays the commits made in your working directory (the directory where you at while running the tool), you can use the -path flag to specify the path to scan for commits in.
```bash
> gitcs -path "/home/username/dev"
```

- If no global Git email is set on your machine, then you have to specify it using the `-email` flag.
- The since and until flags don't need to be specified together.

Expand Down
24 changes: 0 additions & 24 deletions input.go

This file was deleted.

43 changes: 0 additions & 43 deletions input_test.go

This file was deleted.

19 changes: 9 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"bufio"
"flag"
"fmt"
"os"
Expand All @@ -13,11 +12,18 @@ import (
)

func main() {
var email string
wd, err := os.Getwd()
if err != nil {
fmt.Fprint(os.Stderr, color.Red.Sprintf("gitcs: error: %s\n", err.Error()))
os.Exit(1)
}

var email, path string
var sinceflag, untilflag string
flag.StringVar(&sinceflag, "since", "", "start date")
flag.StringVar(&untilflag, "until", "", "end date")
flag.StringVar(&email, "email", strings.TrimSpace(getGlobalEmailFromGit()), "you Git email")
flag.StringVar(&path, "path", wd, "folder path to scan")
flag.Parse()

b, err := setTimeFlags(sinceflag, untilflag)
Expand All @@ -31,20 +37,13 @@ func main() {
os.Exit(1)
}

reader := bufio.NewReader(os.Stdin)
folder, err := getPathFromUser(reader)
if err != nil {
fmt.Fprint(os.Stderr, color.Red.Sprintf("gitcs: error reading input: %s\n", err.Error()))
os.Exit(1)
}

s := spinner.New(spinner.CharSets[6], 100*time.Millisecond, spinner.WithSuffix(" loading..."))

s.Color("green")
s.Start()
defer s.Stop()

repos, err := scanGitFolders(folder)
repos, err := scanGitFolders(path)
if err != nil {
fmt.Fprint(os.Stderr, color.Red.Sprintf("\ngitcs: error: %s\n", err.Error()))
s.Stop()
Expand Down

0 comments on commit 3c6fb29

Please sign in to comment.