Skip to content

Commit

Permalink
adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
jippi committed Feb 15, 2024
1 parent 7809a8f commit 6bb1f4c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
10 changes: 5 additions & 5 deletions cmd/disable/disable.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ func NewCommand() *cobra.Command {

assignment := env.Get(key)
if assignment == nil {
return fmt.Errorf("Could not find KEY [%s]", key)
return fmt.Errorf("Could not find KEY [ %s ]", key)
}

stdout, stderr := tui.WritersFromContext(cmd.Context())

if !assignment.Enabled {
stderr.Warning().Printfln("WARNING: The key [%s] is already disabled", key)
tui.MaybePrintWarnings(cmd.Context(), fmt.Errorf("The key [ %s ] is already disabled", key))

return nil
}
Expand All @@ -46,7 +44,9 @@ func NewCommand() *cobra.Command {
return fmt.Errorf("could not save file: %w", err)
}

stdout.Success().Printfln("Key [%s] was successfully disabled", key)
tui.StdoutFromContext(cmd.Context()).
Success().
Printfln("Key [%s] was successfully disabled", key)

return nil
},
Expand Down
8 changes: 3 additions & 5 deletions cmd/enable/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ func NewCommand() *cobra.Command {

assignment := env.Get(key)
if assignment == nil {
return fmt.Errorf("Could not find KEY [%s]", key)
return fmt.Errorf("Could not find KEY [ %s ]", key)
}

if assignment.Enabled {
tui.StderrFromContext(cmd.Context()).
Warning().
Printfln("WARNING: The key [%s] is already enabled", key)
tui.MaybePrintWarnings(cmd.Context(), fmt.Errorf("The key [ %s ] is already enabled", key))
}

assignment.Enable()
Expand All @@ -46,7 +44,7 @@ func NewCommand() *cobra.Command {

tui.StdoutFromContext(cmd.Context()).
Success().
Printfln("Key [%s] was successfully enabled", key)
Printfln("Key [ %s ] was successfully enabled", key)

return nil
},
Expand Down
3 changes: 1 addition & 2 deletions cmd/print/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ func runE(cmd *cobra.Command, args []string) error {
tui.StdoutFromContext(cmd.Context()).
NoColor().
Println(
render.
NewRenderer(*settings).
render.NewRenderer(*settings).
Statement(cmd.Context(), env).
String(),
)
Expand Down
4 changes: 2 additions & 2 deletions cmd/set/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func runE(cmd *cobra.Command, args []string) error {
for _, stringPair := range args {
pairSlice := strings.SplitN(stringPair, "=", 2)
if len(pairSlice) != 2 {
allErrors = multierr.Append(allErrors, fmt.Errorf("Key: '%s' Error: expected KEY=VALUE pair, missing '='", stringPair))
allErrors = multierr.Append(allErrors, fmt.Errorf("Key [ %s ] Error: expected KEY=VALUE pair, missing '='", stringPair))

continue
}
Expand Down Expand Up @@ -126,7 +126,7 @@ func runE(cmd *cobra.Command, args []string) error {
}
}

stdout.Success().Printfln("Key [%s] was successfully upserted", key)
stdout.Success().Printfln("Key [ %s ] was successfully upserted", key)
}

if allErrors != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/tui/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ func MaybePrintWarnings(ctx context.Context, warnings error) {

StderrFromContext(ctx).
Warning().
Printfln("%+v", warnings)
Printfln("WARNING: %+v", warnings)
}

0 comments on commit 6bb1f4c

Please sign in to comment.