fix(cmd): handle errors and improve output formatting
CI / Test (push) Successful in 28s
CI / Build (push) Successful in 25s

* update error handling in various commands to use blank identifier
* enhance output formatting for better readability
* add golangci-lint to Makefile for linting checks
This commit is contained in:
Hein
2026-07-01 12:53:25 +02:00
parent f17e87e749
commit 04711cf7b2
14 changed files with 80 additions and 82 deletions
+8 -8
View File
@@ -11,7 +11,7 @@ import (
func cmdConfig(args []string, stdin io.Reader, stdout, stderr io.Writer) int {
for _, a := range args {
if a == "-h" || a == "--help" {
fmt.Fprintln(stdout, "pgtidy config — print effective configuration resolved from .pgtidy.yaml")
_, _ = fmt.Fprintln(stdout, "pgtidy config — print effective configuration resolved from .pgtidy.yaml")
return 0
}
}
@@ -21,14 +21,14 @@ func cmdConfig(args []string, stdin io.Reader, stdout, stderr io.Writer) int {
}
st, err := config.Load(wd)
if err != nil {
fmt.Fprintf(stderr, "pgtidy: %v\n", err)
_, _ = fmt.Fprintf(stderr, "pgtidy: %v\n", err)
return 2
}
fmt.Fprintf(stdout, "indent: %q\n", st.Indent)
fmt.Fprintf(stdout, "newline: %q\n", st.Newline)
fmt.Fprintf(stdout, "keyword_case: %s\n", st.KeywordCase)
fmt.Fprintf(stdout, "ident_case: %s\n", st.IdentCase)
fmt.Fprintf(stdout, "type_case: %s\n", st.TypeCase)
fmt.Fprintf(stdout, "commas: %s\n", st.Commas)
_, _ = fmt.Fprintf(stdout, "indent: %q\n", st.Indent)
_, _ = fmt.Fprintf(stdout, "newline: %q\n", st.Newline)
_, _ = fmt.Fprintf(stdout, "keyword_case: %s\n", st.KeywordCase)
_, _ = fmt.Fprintf(stdout, "ident_case: %s\n", st.IdentCase)
_, _ = fmt.Fprintf(stdout, "type_case: %s\n", st.TypeCase)
_, _ = fmt.Fprintf(stdout, "commas: %s\n", st.Commas)
return 0
}