Skip to content
This repository has been archived by the owner on Mar 18, 2022. It is now read-only.

Commit

Permalink
rename no-format flag and remove cli colors, no win support
Browse files Browse the repository at this point in the history
Signed-off-by: Marko Kungla <marko.kungla@gmail.com>
  • Loading branch information
mkungla committed Feb 7, 2022
1 parent ff8f47e commit 8d304ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ USAGE:
koios-rest [global options] command [command options] [arguments...]
VERSION:
0.1.0
(devel)
AUTHOR:
The Howijd.Network Authors
Expand Down Expand Up @@ -320,9 +320,9 @@ GLOBAL OPTIONS:
--schema value Set URL schema (default: "https")
--origin value Set Origin header for requests. (default: "https://github.com/howijd/koios-rest-go-client")
--rate-limit value Set API Client rate limit for outgoing requests (default: 5)
--ugly Ugly prints response json strings directly without calling json pretty. (default: false)
--no-format prints response json strings directly without calling json pretty. (default: false)
--enable-req-stats Enable request stats. (default: false)
--no-color Disable coloring output json. (default: false)
--testnet use default testnet as host. (default: false)
--help, -h show help (default: false)
--version, -v print the version (default: false)
Expand Down
25 changes: 6 additions & 19 deletions cmd/koios-rest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,12 @@ func handleErr(err error) {
}

func printResponseBody(ctx *cli.Context, body []byte) {
if ctx.Bool("ugly") {
if ctx.Bool("no-color") {
fmt.Println(string(body))
return
}
fmt.Println(string(pretty.Color(body, pretty.TerminalStyle)))
if ctx.Bool("no-format") {
fmt.Println(string(body))
return
}
pr := pretty.Pretty(body)
if ctx.Bool("no-color") {
fmt.Println(string(pr))
return
}
fmt.Println(string(pretty.Color(pr, pretty.TerminalStyle)))
fmt.Println(string(pretty.Pretty(body)))
return
}

type printable interface {
Expand Down Expand Up @@ -169,20 +161,15 @@ func globalFlags() []cli.Flag {
Value: uint(koios.DefaultRateLimit),
},
&cli.BoolFlag{
Name: "ugly",
Usage: "Ugly prints response json strings directly without calling json pretty.",
Name: "no-format",
Usage: "prints response json strings directly without calling json pretty.",
Value: false,
},
&cli.BoolFlag{
Name: "enable-req-stats",
Usage: "Enable request stats.",
Value: false,
},
&cli.BoolFlag{
Name: "no-color",
Usage: "Disable coloring output json.",
Value: false,
},
&cli.BoolFlag{
Name: "testnet",
Usage: "use default testnet as host.",
Expand Down

0 comments on commit 8d304ca

Please sign in to comment.