Skip to content

Commit

Permalink
Spinner eats messages (#149)
Browse files Browse the repository at this point in the history
* Clean up spinner finalization.

* Stop eating regular log messages alongside spinner usage.
  • Loading branch information
grayside authored and febbraro committed Mar 2, 2018
1 parent 806e0ee commit b8f97f8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
15 changes: 8 additions & 7 deletions commands/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,24 @@ func (cmd *BaseCommand) Before(c *cli.Context) error {

// Success encapsulates the functionality for reporting command success
func (cmd *BaseCommand) Success(message string) error {
// Handle success messaging.
// Handle success messaging. If the spinner is running or not, this will
// output accordingly and issue a notification.
if message != "" {
cmd.out.Info(message)
util.NotifySuccess(cmd.context, message)
}

// If there is an active spinner wrap it up. This is not placed before the logging above so commands can rely on
// cmd.Success to set the last spinner status in lieu of an extraneous log entry.
cmd.out.NoSpin()

return nil
}

// Failure encapsulates the functionality for reporting command failure
func (cmd *BaseCommand) Failure(message string, errorName string, exitCode int) error {
// Make sure any running spinner halts.
cmd.out.NoSpin()
// If the spinner is running, output something to get closure and shut it down.
if cmd.out.Spinning {
cmd.out.Error(message)
fmt.Println()
}

// Handle error messaging.
util.NotifyError(cmd.context, message)
// Print expanded troubleshooting guidance.
Expand Down
4 changes: 1 addition & 3 deletions commands/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,10 @@ func (cmd *Start) Run(c *cli.Context) error {
cmd.out.Error("Docker could not be started")
return cmd.Failure(err.Error(), "MACHINE-START-FAILED", 12)
}
cmd.out.Info("Docker Machine (%s) Created", cmd.machine.Name)

cmd.out.Verbose("Configuring the local Docker environment")
cmd.machine.SetEnv()
cmd.out.Info("Docker Machine is ready")
cmd.out.Info("Docker Machine (%s) Created", cmd.machine.Name)

dns := DNS{cmd.BaseCommand}
dns.StartDNS(cmd.machine, c.String("nameservers"))
Expand Down Expand Up @@ -148,7 +147,6 @@ func (cmd *Start) Run(c *cli.Context) error {

cmd.out.Info("Run 'eval \"$(rig config)\"' to execute docker or docker-compose commands in your terminal.")
return cmd.Success("Outrigger is ready to use")

}

// StartMinimal will start "minimal" Outrigger operations, which refers to environments where
Expand Down
3 changes: 3 additions & 0 deletions util/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func (log *RigLogger) Info(format string, a ...interface{}) {
} else {
log.Progress.Spins.SetMessage(fmt.Sprintf(format, a...))
log.Progress.Spins.Succeed()
log.Spinning = false
}
}

Expand All @@ -123,6 +124,7 @@ func (log *RigLogger) Warning(format string, a ...interface{}) {
} else {
log.Progress.Spins.SetMessage(fmt.Sprintf(format, a...))
log.Progress.Spins.Warn()
log.Spinning = false
}
}

Expand All @@ -138,6 +140,7 @@ func (log *RigLogger) Error(format string, a ...interface{}) {
} else {
log.Progress.Spins.SetMessage(fmt.Sprintf(format, a...))
log.Progress.Spins.Fail()
log.Spinning = false
}
}

Expand Down

0 comments on commit b8f97f8

Please sign in to comment.