Skip to content

Commit b3fe132

Browse files
author
Mehrad
committed
Support Colorful Output
1 parent d0b976a commit b3fe132

46 files changed

Lines changed: 1835 additions & 244 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/activity.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cmd
22

33
import (
4+
"log"
45
"sort"
56
"strconv"
67

cmd/application.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package cmd
22

33
import (
4-
"github.com/spf13/cobra"
54
"fmt"
5+
"log"
6+
"github.com/spf13/cobra"
67
ybApi "github.com/yottab/proto-api/proto"
78
)
89

cmd/auth.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cmd
22

33
import (
4+
"log"
45
"github.com/spf13/cobra"
56
"github.com/spf13/viper"
67
"github.com/yottab/cli/config"
@@ -34,7 +35,7 @@ func login(cmd *cobra.Command, args []string) {
3435
}
3536

3637
if len(password) != 0 {
37-
log.Warn("WARNING! Using --password via the CLI is insecure. use it in the case of need, for example: a secured build pipeline")
38+
log.Println("WARNING! Using --password via the CLI is insecure. use it in the case of need, for example: a secured build pipeline")
3839
} else {
3940
password = readPasswordFromConsole("Password: ")
4041
}

cmd/build.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cmd
22

33
import (
44
"fmt"
5+
"log"
56
"io"
67
"io/ioutil"
78
"os"

cmd/color.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package cmd
2+
3+
import (
4+
"github.com/fatih/color"
5+
"fmt"
6+
)
7+
8+
var(
9+
mainColor = color.BgBlue
10+
secColor = color.BgYellow
11+
mainTxt = color.New(color.FgHiWhite, color.BgBlack, color.Bold)
12+
mainTxtSprint = mainTxt.SprintFunc()
13+
mainTxtColor = mainTxt.SprintfFunc()
14+
secTxtColor = color.New(color.FgWhite, color.BgBlack, color.Faint).SprintfFunc()
15+
mainTxtBlink = color.New(color.FgHiWhite, color.BgBlack, color.Bold, color.BlinkSlow).SprintfFunc()
16+
mainTitle = color.New(color.FgHiWhite, mainColor, color.Bold)
17+
mainTitleColor = mainTitle.SprintfFunc()
18+
mainTitlePrint = mainTitle.SprintFunc()
19+
secTitleColor = color.New(color.FgBlack, secColor, color.Bold).SprintfFunc()
20+
secTitleBlink = color.New(color.FgBlack, secColor, color.Bold, color.BlinkSlow).SprintfFunc()
21+
whiteSpace = " "
22+
whiteSpaceDash = " - "
23+
)
24+
25+
func mainTxtPrintln(body ...interface{}){ fmt.Println(mainTxtSprint(body...)) }
26+
func colorfulPrintln(body ...interface{}){ fmt.Println(mainTitlePrint(body...)) }
27+
func colorfulPrint(body ...interface{}){ fmt.Print(mainTitlePrint(body...)) }
28+
29+
func printKeyVal(space, k, v string){
30+
fmt.Printf("%s:%s \r\n",
31+
mainTxtColor(" %s%s ", space, k),
32+
secTxtColor(" %s ", v))
33+
}
34+
35+
func printTitleByStatus(space, title, status string){
36+
if status == "Unreachable" {
37+
fmt.Printf("%s%s:%s\r\n",
38+
space,
39+
secTitleColor(" %s ", title),
40+
secTitleBlink(" # [Unreachable] "))
41+
} else {
42+
fmt.Printf("%s%s:\r\n",
43+
space,
44+
mainTitleColor(" %s ", title))
45+
}
46+
}
47+
48+
func printTitle(space, title string){
49+
fmt.Printf("%s%s:\r\n",
50+
space,
51+
mainTitleColor(" %s ", title))
52+
}

cmd/command_cli.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"bufio"
55
"fmt"
6+
"log"
67
"os"
78
"strings"
89

@@ -88,12 +89,12 @@ func SelfUpdate(latestAvailable *selfupdate.Release) {
8889
fmt.Print("Do you want to update? [Y/n]: ")
8990
input, err := bufio.NewReader(os.Stdin).ReadString('\n')
9091
if err != nil {
91-
log.Error("Error while reading from stdin!")
92+
log.Println("Error while reading from stdin!")
9293
return
9394
}
9495
input = strings.ToLower(strings.TrimSpace(input))
9596
if input != "y" && input != "" {
96-
log.Print("Update canceled!")
97+
log.Println("Update canceled!")
9798
return
9899
}
99100

cmd/command_create_update.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,13 @@ func init() {
8181
srvCreateCmd.MarkFlagRequired("name")
8282

8383
// application Create flag:
84-
appCreateCmd.Flags().StringP("plan", "s", "", "name of plan")
84+
appCreateCmd.Flags().StringP("plan", "", "default", "name of plan")
8585
appCreateCmd.Flags().StringP("name", "n", "", "a uniquely identifiable name for the application. No other app can already exist with this name.")
8686
appCreateCmd.Flags().Uint64VarP(&flagVarPort, "port", "p", 0, "port of application")
8787
appCreateCmd.Flags().StringVarP(&flagVarImage, "image", "i", "", "image of application")
88-
appCreateCmd.Flags().StringVarP(&flagVarEndpointType, "endpoint-type", "e", "http", "Accepted values: http|grpc, default to http")
88+
appCreateCmd.Flags().StringVarP(&flagVarEndpointType, "endpoint-type", "e", "http", "Accepted values: http|grpc|private")
8989
appCreateCmd.Flags().Uint64VarP(&flagVarMinScale, "min-scale", "m", 1, "min scale of application")
90+
appCreateCmd.MarkFlagRequired("name")
9091
appCreateCmd.MarkFlagRequired("image")
9192

9293
// domain create:

cmd/command_link.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cmd
22

33
import (
4+
"log"
45
"github.com/spf13/cobra"
56
)
67

cmd/command_listType.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cmd
22

33
import (
4+
"log"
45
"github.com/spf13/cobra"
56
)
67

cmd/command_push.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cmd
22

33
import (
4+
"log"
45
"os"
56
"runtime"
67
"strings"

0 commit comments

Comments
 (0)