Skip to content

Commit e511e8d

Browse files
committed
Added color for warning/error in cli
1 parent f5bdde4 commit e511e8d

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

cmd/clace/app_cmds.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
const (
2222
DRY_RUN_FLAG = "dry-run"
2323
DRY_RUN_ARG = "dryRun"
24-
DRY_RUN_MESSAGE = "\n*** dry-run mode, changes have NOT been committed. ***\n"
24+
DRY_RUN_MESSAGE = "\n" + YELLOW + "*** dry-run mode, changes have NOT been committed. ***" + RESET + "\n"
2525
PATH_SPEC_HELP = `The (optional) domain and path are separated by a ":". appPathGlob supports a glob pattern.
2626
In the glob, * matches any number of characters, ** matches any number of characters including /.
2727
all is a shortcut for "*:**", which matches all apps across all domains, including no domain.

cmd/clace/flags.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ const (
2222
FORMAT_JSONL_PRETTY = "jsonl_pretty"
2323
FORMAT_CSV = "csv"
2424
)
25+
const (
26+
//Terminal colors
27+
RESET = "\033[0m"
28+
RED = "\033[31m"
29+
GREEN = "\033[32m"
30+
YELLOW = "\033[33m"
31+
)
2532

2633
func envString(name string) string {
2734
return fmt.Sprintf("CL_%s", strings.ToUpper(strings.ReplaceAll(name, ".", "_")))

cmd/clace/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func main() {
198198
},
199199
ExitErrHandler: func(c *cli.Context, err error) {
200200
if err != nil {
201-
fmt.Fprintf(cli.ErrWriter, "error: %s\n", err)
201+
fmt.Fprintf(cli.ErrWriter, RED+"error: %s\n"+RESET, err)
202202
os.Exit(1)
203203
}
204204
},

tests/commander/test_load_app.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ tests:
2323
stdout: "app /disk_usage_dev is not permitted to load plugin fs.in. Audit the app and approve permissions"
2424
load0041: # check audit output
2525
command: '../clace app approve --dry-run /disk_usage_dev | sed "s/app_dev_.*/YYY/g"'
26-
stdout:
27-
exactly: "App permissions have been approved /disk_usage_dev - YYY\n Plugins :\n fs.in\n Permissions:\n fs.in.abs [] \n fs.in.list [] \n fs.in.find [] \n1 app(s) audited, 1 app(s) approved, 0 app(s) promoted.\n\n*** dry-run mode, changes have NOT been committed. ***\n"
26+
stdout: "dry-run mode, changes have NOT been committed."
2827
exit-code: 0
2928
load0041a: # test dev app, make sure dry run did not update the in memory cache
3029
command: curl -su "admin:qwerty" localhost:25222/disk_usage_dev

tests/test_basics.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@ tests:
1212

1313
basic020:
1414
command: CL_CONFIG_FILE=config_basic_client_np.toml ../clace app list /invalid
15-
stderr:
16-
exactly: "error: 404 page not found" # admin api's are disabled over http
15+
stderr: "error: 404 page not found" # admin api's are disabled over http
1716
stdout:
1817
line-count: 0
1918
exit-code: 1
2019

2120
basic030:
2221
command: CL_CONFIG_FILE=config_basic_client.toml ../clace app list /invalid # No app
23-
stderr:
24-
exactly: "error: 404 page not found" # admin api's are disabled over http
22+
stderr: "error: 404 page not found" # admin api's are disabled over http
2523
stdout:
2624
line-count: 0
2725
exit-code: 1

0 commit comments

Comments
 (0)