fix(cmd): handle errors and improve output formatting
* 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:
+3
-3
@@ -29,20 +29,20 @@ func run(args []string, stdin io.Reader, stdout, stderr io.Writer) int {
|
||||
case "config":
|
||||
return cmdConfig(args[1:], stdin, stdout, stderr)
|
||||
case "version", "--version", "-v":
|
||||
fmt.Fprintf(stdout, "pgtidy %s\n", version)
|
||||
_, _ = fmt.Fprintf(stdout, "pgtidy %s\n", version)
|
||||
return 0
|
||||
case "help", "-h", "--help":
|
||||
usage(stdout)
|
||||
return 0
|
||||
default:
|
||||
fmt.Fprintf(stderr, "pgtidy: unknown command %q\n", args[0])
|
||||
_, _ = fmt.Fprintf(stderr, "pgtidy: unknown command %q\n", args[0])
|
||||
usage(stderr)
|
||||
return 2
|
||||
}
|
||||
}
|
||||
|
||||
func usage(w io.Writer) {
|
||||
fmt.Fprint(w, `pgtidy — PostgreSQL formatter and linter
|
||||
_, _ = fmt.Fprint(w, `pgtidy — PostgreSQL formatter and linter
|
||||
|
||||
Usage:
|
||||
pgtidy fmt [flags] [files...] Format SQL/PL-pgSQL (stdin if no files)
|
||||
|
||||
Reference in New Issue
Block a user