Skip to content

Commit

Permalink
Move more logic to main
Browse files Browse the repository at this point in the history
  • Loading branch information
akupila committed Sep 26, 2018
1 parent cc92a31 commit ef6e141
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 36 deletions.
11 changes: 10 additions & 1 deletion cmd/gitprompt/gitprompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,14 @@ func main() {
os.Exit(0)
}

gitprompt.Exec(format.String(), *zsh)
s, err := gitprompt.Parse()
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
out, num := gitprompt.Print(s, format.String())
_, _ = fmt.Fprint(os.Stdout, out)
if *zsh {
_, _ = fmt.Fprintf(os.Stdout, "%%%dG", num)
}
}
35 changes: 0 additions & 35 deletions git.go

This file was deleted.

12 changes: 12 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ import (
"strings"
)

// GitStatus is the parsed status for the current state in git.
type GitStatus struct {
Sha string
Branch string
Untracked int
Modified int
Staged int
Conflicts int
Ahead int
Behind int
}

// Parse parses the status for the repository from git. Returns nil if the
// current directory is not part of a git repository.
func Parse() (*GitStatus, error) {
Expand Down

0 comments on commit ef6e141

Please sign in to comment.