Skip to content

Commit

Permalink
fix: typos and log changes
Browse files Browse the repository at this point in the history
  • Loading branch information
seriouspoop committed Aug 29, 2024
1 parent 183bb1d commit a593a2e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
15 changes: 8 additions & 7 deletions internal/handler/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func Run(s servicer) *cobra.Command {
return err
}

utils.Logger(utils.STATUS_INFO, "Pulling remote changes...")
utils.Logger(utils.LOG_INFO, "Pulling remote changes...")
err = s.Pull(false)
if err != nil {
if errors.Is(err, svc.ErrAuthNotFound) {
Expand All @@ -71,7 +71,7 @@ func Run(s servicer) *cobra.Command {
}
return err
}
utils.Logger(utils.STATUS_SUCCESS, "changes fetched")
utils.Logger(utils.LOG_SUCCESS, "changes fetched")
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -91,16 +91,17 @@ func Run(s servicer) *cobra.Command {
}

// Generate Tests and Run
utils.Logger(utils.LOG_INFO, "Generating and Running tests...")
testValid, err := s.CheckTestsAndRun()
if err != nil {
return err
}
if testValid {
utils.Logger(utils.STATUS_SUCCESS, "All tests passed")
utils.Logger(utils.LOG_SUCCESS, "tests passed")
} else {
utils.Logger(utils.STATUS_FAILURE, "No tests found")
utils.Logger(utils.LOG_FAILURE, "no tests found")
}
utils.Logger(utils.STATUS_INFO, "Staging changes...")
utils.Logger(utils.LOG_INFO, "Staging changes...")

// stage changes
err = s.StageChanges()
Expand All @@ -111,7 +112,7 @@ func Run(s servicer) *cobra.Command {
//TODO -> pull and merge from main

// Push changes
utils.Logger(utils.STATUS_INFO, "Pushing changes...")
utils.Logger(utils.LOG_INFO, "Pushing changes...")
output, err := s.Push(setUpstreamBranch)
if err != nil {
if output != "" {
Expand All @@ -120,7 +121,7 @@ func Run(s servicer) *cobra.Command {
if errors.Is(err, svc.ErrAuthNotFound) {
fmt.Println(heredoc.Doc(`
Auth credentials for current remote are missing.
Run "gopush init" first to setup auth credentials.
Run "gopush init" to setup auth credentials.
`))
}
return err
Expand Down
6 changes: 3 additions & 3 deletions svc/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (s *Svc) InitializeRepo() error {
return err
}

utils.Logger(utils.STATUS_SUCCESS, "Repository initialized")
utils.Logger(utils.LOG_SUCCESS, "repository initialized")
return nil
}

Expand Down Expand Up @@ -162,7 +162,7 @@ func (s *Svc) StageChanges() error {
if err != nil {
return err
}
utils.Logger(utils.STATUS_SUCCESS, "Files added")
utils.Logger(utils.LOG_SUCCESS, "files added")
}
return nil
}
Expand Down Expand Up @@ -195,6 +195,6 @@ func (s *Svc) Push(setUpstreamBranch bool) (output string, err error) {
return "", err
}
}
utils.Logger(utils.STATUS_SUCCESS, "Push Successful")
utils.Logger(utils.LOG_SUCCESS, "push successful")
return
}
1 change: 0 additions & 1 deletion svc/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ func (s *Svc) CheckTestsAndRun() (bool, error) {
return false, err
}
if present {
fmt.Println("\nGenerating and Running tests...")
output, _ := s.bash.GenerateMocks()
fmt.Print(output)
output, err := s.bash.RunTests()
Expand Down
26 changes: 13 additions & 13 deletions utils/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ var green = color.New(color.FgGreen).SprintFunc()
var red = color.New(color.FgRed).SprintFunc()
var faint = color.New(color.Faint).SprintFunc()

type status int
type log int

const (
STATUS_UNKNOWN status = iota
STATUS_INFO
STATUS_SUCCESS
STATUS_FAILURE
LOG_UNKNOWN log = iota
LOG_INFO
LOG_SUCCESS
LOG_FAILURE
)

func Logger(s status, log string) {
statusToUnicode := map[status]string{
STATUS_INFO: "",
STATUS_SUCCESS: green("\U00002714 "),
STATUS_FAILURE: red("\U00002717 "),
func Logger(s log, msg string) {
statusToUnicode := map[log]string{
LOG_INFO: "",
LOG_SUCCESS: green("\U00002714 "),
LOG_FAILURE: red("\U00002717 "),
}

if s != STATUS_INFO {
log = faint(log)
if s != LOG_INFO {
msg = faint(msg)
}

fmt.Printf("%s%s\n", statusToUnicode[s], log)
fmt.Printf("%s%s\n", statusToUnicode[s], msg)
}

0 comments on commit a593a2e

Please sign in to comment.