Skip to content

Commit 3b47c97

Browse files
docs: document FormatterOption and opts param; test: add --raw-errors long-form case
1 parent 23595cd commit 3b47c97

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

cmd/sqlcmd/sqlcmd_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ func TestValidCommandLineToArgsConversion(t *testing.T) {
126126
{[]string{"-j"}, func(args SQLCmdArguments) bool {
127127
return args.RawErrors
128128
}},
129+
{[]string{"--raw-errors"}, func(args SQLCmdArguments) bool {
130+
return args.RawErrors
131+
}},
129132
}
130133

131134
for _, test := range commands {

pkg/sqlcmd/format.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ type sqlCmdFormatterType struct {
8888
rawErrors bool
8989
}
9090

91-
// FormatterOption configures a Formatter returned by NewSQLCmdDefaultFormatter.
91+
// FormatterOption customizes the default formatter built by NewSQLCmdDefaultFormatter.
92+
// Use the provided With* constructors (e.g. WithRawErrors) to supply options.
9293
type FormatterOption func(*sqlCmdFormatterType)
9394

9495
// WithRawErrors controls AddError prefix handling: when raw is true, AddError
@@ -100,7 +101,7 @@ func WithRawErrors(raw bool) FormatterOption {
100101

101102
// NewSQLCmdDefaultFormatter returns a Formatter based on the configuration.
102103
// It returns an ASCII formatter if the format is set to "ascii", otherwise it returns a formatter that mimics the original ODBC-based sqlcmd formatter.
103-
// FormatterOption values (e.g. WithRawErrors) apply only to the ODBC-mimicking formatter; the ASCII formatter ignores them.
104+
// Any FormatterOption values passed via opts (e.g. WithRawErrors) are applied to the ODBC-mimicking formatter; the ASCII formatter ignores them.
104105
func NewSQLCmdDefaultFormatter(vars *Variables, removeTrailingSpaces bool, ccb ControlCharacterBehavior, opts ...FormatterOption) Formatter {
105106
if vars.Format() == "ascii" {
106107
return NewSQLCmdAsciiFormatter(vars, removeTrailingSpaces, ccb)

0 commit comments

Comments
 (0)