Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Fixes #813: Improve error handling for config get command #815

Merged
merged 1 commit into from
Nov 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions internal/cli/config_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,18 @@ func (c *ConfigGetCommand) Run(args []string) int {
return 1
}

if prefix == "" {
fmt.Fprintf(os.Stderr, "flag '-raw' requires a named variable argument to be given")
return 1
}

if len(resp.Variables) == 0 {
fmt.Fprintf(os.Stderr, "named variable '%s' was not found in config", prefix)
return 1
}

if resp.Variables[0].Name != prefix {
fmt.Fprintf(os.Stderr, "name '%s' doesn't match prefix: %s", resp.Variables[0].Name, prefix)
return 1
}

Expand Down