Skip to content

Commit

Permalink
Color fixes for recording, auth track github login, makefile fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisT committed May 25, 2019
1 parent f467dd9 commit 856f27c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ install:
uninstall:
go clean -i
test:
go vet ./...
go test -v ./...
clean:
go clean
rm -rf ./builds/termbacktime*
run:
go run -v ${LDFLAGS} ./...
go run -v ${LDFLAGS} ./main.go
13 changes: 8 additions & 5 deletions cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ func uuid() string {
return fmt.Sprintf("%x-%x-%x%x-%x%x-%x", b[0:4], b[4:6], (b[6]&0x0f)|0x40, b[7:8], (b[8]&0x3f)|0x80, b[9:10], b[10:])
}

func saveToken(tkn string, man bool) {
func saveToken(tkn string, usr string, man bool) {
if man {
fmt.Printf("Saving token: %s\r\n", tkn)
}
viper.Set("token", tkn)
if len(usr) > 0 {
viper.Set("login", usr)
}
if err := viper.WriteConfig(); err == nil {
fmt.Println(au.Sprintf(au.Bold("Saved config: %s"), viper.ConfigFileUsed()))
os.Exit(0)
Expand All @@ -66,7 +69,7 @@ var authCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
tkn := cmd.Flag("set-token").Value.String()
if len(tkn) > 0 {
saveToken(tkn, true)
saveToken(tkn, "", true)
} else {
client, err := ably.NewRealtimeClient(ably.NewClientOptions(AblyToken))
if err != nil {
Expand All @@ -86,8 +89,8 @@ var authCmd = &cobra.Command{

go func() {
ticker := time.Tick(time.Second)
fmt.Print(colorify("Waiting for token; timeout in %d seconds...", 30))
for i := 29; i >= 0; i-- {
fmt.Print(colorify("Waiting for token; timeout in %d seconds...", 60))
for i := 59; i >= 0; i-- {
<-ticker
fmt.Printf("\r%s", colorify("Waiting for token; timeout in %d seconds...", i))
}
Expand All @@ -99,7 +102,7 @@ var authCmd = &cobra.Command{
if data, ok := msg.Data.(map[string]interface{}); ok {
if data["login"] != "" {
fmt.Printf("\rLogged in as %s - Token: %s\r\n", data["login"], data["token"])
saveToken(fmt.Sprintf("%s", data["token"]), false)
saveToken(fmt.Sprintf("%s", data["token"]), fmt.Sprintf("%s", data["login"]), false)
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions cmd/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var (
Closed bool
GistResponse map[string]interface{}
GithubToken string
GithubLogin string
HomeDir = getHome()
Instructions []Lines
spinner = spin.New("%s Working...")
Expand Down Expand Up @@ -200,7 +201,12 @@ var recordCmd = &cobra.Command{
return Error(fmt.Errorf("missing GitHub authentication token"))
}
}
fmt.Println(au.Bold("Initiating terminal recording..."))
GithubLogin = viper.GetString("login")
if len(GithubLogin) > 0 {
fmt.Println(au.Sprintf(au.Bold("Initiating terminal recording for %s..."), GithubLogin))
} else {
fmt.Println(au.Bold("Initiating terminal recording..."))
}

// Start recording Object.
ccmd := shell(cmd)
Expand Down Expand Up @@ -278,7 +284,7 @@ var recordCmd = &cobra.Command{
}
}(chn)

fmt.Println(au.Red(au.Bold("Recording started!\r\n")))
fmt.Println(au.Green(au.Bold("Recording started!\r\n")))

// Read from the PTY into a buffer.
rectime := time.Now()
Expand Down

0 comments on commit 856f27c

Please sign in to comment.