* update error handling in various commands to use blank identifier * enhance output formatting for better readability * add golangci-lint to Makefile for linting checks
35 lines
906 B
Go
35 lines
906 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
|
|
"git.warky.dev/wdevs/pgtidy/pkg/config"
|
|
)
|
|
|
|
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")
|
|
return 0
|
|
}
|
|
}
|
|
wd, err := os.Getwd()
|
|
if err != nil {
|
|
wd = "."
|
|
}
|
|
st, err := config.Load(wd)
|
|
if err != nil {
|
|
_, _ = 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)
|
|
return 0
|
|
}
|