-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
10 changed files
with
132 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package rocket | ||
|
||
// The last error returned from the RocketChat API | ||
var LastError Error | ||
|
||
type Error struct { | ||
Status string `json:"status"` | ||
Error string `json:"status"` | ||
Message string `json:"status"` | ||
} |
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ import ( | |
) | ||
|
||
const ( | ||
version = "1.0.0" | ||
version = "1.0.1" | ||
) | ||
|
||
var rootCommand = &cobra.Command{ | ||
|
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
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,16 @@ | ||
package util | ||
|
||
import "fmt" | ||
|
||
var ( | ||
Red = Color("\033[1;31m%s\033[0m") | ||
Green = Color("\033[1;32m%s\033[0m") | ||
) | ||
|
||
func Color(colorString string) func(...interface{}) string { | ||
sprint := func(args ...interface{}) string { | ||
return fmt.Sprintf(colorString, | ||
fmt.Sprint(args...)) | ||
} | ||
return sprint | ||
} |
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,50 @@ | ||
package util | ||
|
||
import ( | ||
"fmt" | ||
"github.com/briandowns/spinner" | ||
"os" | ||
"time" | ||
) | ||
|
||
type Spinner struct { | ||
spinner *spinner.Spinner | ||
} | ||
|
||
const ( | ||
IconSuccess = "✓" | ||
IconError = "✘" | ||
|
||
NoMessage = "" | ||
) | ||
|
||
func StartSpinner(title string) *Spinner { | ||
spin := spinner.New(spinner.CharSets[14], 100 * time.Millisecond, spinner.WithWriter(os.Stderr)) | ||
spin.Suffix = " " + title | ||
spin.HideCursor = true | ||
spin.Start() | ||
return &Spinner{spinner: spin} | ||
} | ||
|
||
func (spin *Spinner) StopSuccessRemove() { | ||
spin.spinner.Stop() | ||
} | ||
|
||
func (spin *Spinner) StopSuccess(message string) { | ||
spin.spinner.Stop() | ||
|
||
if message == NoMessage { | ||
fmt.Fprintf(os.Stderr, "%s%s\n", Green(IconSuccess), spin.spinner.Suffix) | ||
} else { | ||
fmt.Fprintf(os.Stderr, "%s%s - %s\n", Green(IconSuccess), spin.spinner.Suffix, message) | ||
} | ||
} | ||
|
||
func (spin *Spinner) StopError(err error) { | ||
spin.spinner.Stop() | ||
fmt.Fprintf(os.Stderr, "%s%s - %s\n", Red(IconError), spin.spinner.Suffix, Red("(" + err.Error() + ")")) | ||
} | ||
|
||
func (spin *Spinner) UpdateMessage(message string) { | ||
spin.spinner.Suffix = " " + message | ||
} |