Skip to content

Commit 7270f01

Browse files
docs: document FormatterOption and opts param; test: add --raw-errors long-form case
1 parent a65bd09 commit 7270f01

2 files changed

Lines changed: 7 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: 4 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
@@ -98,7 +99,8 @@ func WithRawErrors(raw bool) FormatterOption {
9899
return func(f *sqlCmdFormatterType) { f.rawErrors = raw }
99100
}
100101

101-
// NewSQLCmdDefaultFormatter returns a Formatter that mimics the original ODBC-based sqlcmd formatter
102+
// NewSQLCmdDefaultFormatter returns a Formatter that mimics the original ODBC-based sqlcmd formatter.
103+
// Any FormatterOption values passed via opts (e.g. WithRawErrors) are applied to the new formatter.
102104
func NewSQLCmdDefaultFormatter(removeTrailingSpaces bool, ccb ControlCharacterBehavior, opts ...FormatterOption) Formatter {
103105
f := &sqlCmdFormatterType{
104106
removeTrailingSpaces: removeTrailingSpaces,

0 commit comments

Comments
 (0)