Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ EXE=$(shell $(GO) env GOEXE)

build:
$(GO) fmt ./...
$(SET) "CGO_ENABLED=0" && $(GO) build $(GOOPT) "./cmd/$(NAME)"
$(SET) "CGO_ENABLED=0" && $(GO) build -tags debug $(GOOPT) "./cmd/$(NAME)"

test:
$(GO) test ./...
Expand Down
12 changes: 10 additions & 2 deletions edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ func askN(msg string, getKey func() (string, error), options ...string) (int, er
func newViewer(ss *session) *spread.Viewer {
var hl int
if ss.Debug {
hl = 3
hl = 2
} else {
hl = 1
}
return &spread.Viewer{
Entry: ss.Dialect,
HeaderLines: hl,
Debug: ss.Debug,
Comma: ss.comma(),
Null: ss.Null,
Spool: ss.spool,
Expand All @@ -80,10 +81,17 @@ func chooseTable(ctx context.Context, tables []string, d *dialect.Entry, ttyout
}

func doEdit(ctx context.Context, ss *session, command string, pilot commandIn) error {
var hl int
if ss.Debug {
hl = 2
} else {
hl = 1
}
editor := &spread.Editor{
Viewer: &spread.Viewer{
Entry: ss.Dialect,
HeaderLines: 1,
HeaderLines: hl,
Debug: ss.Debug,
Comma: ss.comma(),
Null: ss.Null,
},
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
github.com/nyaosorg/go-box/v3 v3.1.1
github.com/nyaosorg/go-readline-ny v1.15.1
github.com/nyaosorg/go-ttyadapter v0.7.0
github.com/nyaosorg/go-windows-dbg v0.1.0
github.com/sijms/go-ora/v2 v2.8.22
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ github.com/nyaosorg/go-readline-skk v0.6.2 h1:UUBt4qS0UwEaqKgaju8yQOogSF0Ozs4KXH
github.com/nyaosorg/go-readline-skk v0.6.2/go.mod h1:afNC+dqTeuu+5KHNFjbv/up7bfehvHp6HULXljTzvyw=
github.com/nyaosorg/go-ttyadapter v0.7.0 h1:iBOlx7WJ+A0Fn1x28qYJNedjiFt/kWivlrn1+PTSViU=
github.com/nyaosorg/go-ttyadapter v0.7.0/go.mod h1:w6ySb/Y8rpr0uIju4vN/TMRHC/6ayabORHmEVs6d/qE=
github.com/nyaosorg/go-windows-dbg v0.1.0 h1:nJt8s4GVavdaHW8TFUyjsCDQkXS+CH3sqalu7y9Z5OY=
github.com/nyaosorg/go-windows-dbg v0.1.0/go.mod h1:2KBQW9Jv7m6jB8WDgvZOVsJXwtbk4MRIpOWt/n/EDwg=
github.com/nyaosorg/go-windows-mbcs v0.4.4 h1:x5MqDvOsfRO8F2a9Uedlm3I6SB/H0whN4KZknTOLe3w=
github.com/nyaosorg/go-windows-mbcs v0.4.4/go.mod h1:P610Wyc6LcgDbx2VZhwUQn02XRuwjqGK2l/3wox3auA=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
Expand Down
11 changes: 11 additions & 0 deletions internal/dbg/debug.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build debug

package dbg

import (
"github.com/nyaosorg/go-windows-dbg"
)

func Println(v ...any) {
dbg.Println(v...)
}
5 changes: 5 additions & 0 deletions internal/dbg/ndebug.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//go:build !debug

package dbg

func Println(v ...any) {}
7 changes: 0 additions & 7 deletions run-mssql.cmd

This file was deleted.

9 changes: 0 additions & 9 deletions run-mysql.cmd

This file was deleted.

6 changes: 0 additions & 6 deletions run-oracle.cmd

This file was deleted.

11 changes: 0 additions & 11 deletions run-psql.cmd

This file was deleted.

5 changes: 0 additions & 5 deletions run-sqlite3.cmd

This file was deleted.

34 changes: 34 additions & 0 deletions run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@setlocal
@set PROMPT=$G$S
@call :"%~1" %2 %3 %4 %5 %6 %7 %8 %9
@endlocal
@exit /b

:"sqlite"
:"sqlite3"
sqlbless %* sqlite3 mytestdb
@exit /b

:"mssql"
:"sqlserver"
sqlbless %* sqlserver "Server=localhost\SQLEXPRESS;Database=master;Trusted_Connection=True;protocol=lpc;"
@exit /b

:"mysql"
sqlbless %* mysql "root:@/mydb"
@exit /b

:"oracle"
sqlbless %* oracle://scott:tiger@localhost:1521/xepdb1
@exit /b

:"psql"
@rem Driver: https://github.com/lib/pq
@rem Schema postgresql://${username}:${password}@localhost:${port}/${database}?options=--search_path%3D${schema}"
sqlbless %* postgres://postgres@127.0.0.1:5432/chinook?sslmode=disable
@exit /b

:"-psql"
psql -h 127.0.0.1 -p 5432 -d postgres -U postgres
@exit /b

1 change: 1 addition & 0 deletions spread/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ func (editor *Editor) Edit(ctx context.Context, tableAndWhere string, termOut io
Null: editor.Viewer.Null,
Comma: rune(editor.Viewer.Comma),
AutoClose: true,
Debug: editor.Viewer.Debug,
Conv: func(_ int, ct *sql.ColumnType, v any) (string, bool) {
if f := editor.Entry.FormatValue; f != nil {
return f(ct.DatabaseTypeName(), v)
Expand Down
2 changes: 2 additions & 0 deletions spread/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type KeyBinding struct {
type Viewer struct {
*dialect.Entry
HeaderLines int
Debug bool
Comma byte
Null string
Spool io.Writer
Expand All @@ -44,6 +45,7 @@ func (viewer *Viewer) View(ctx context.Context, title string, rows rowstocsv.Sou
Null: viewer.Null,
Comma: rune(viewer.Comma),
AutoClose: true,
Debug: viewer.Debug,
Conv: func(_ int, ct *sql.ColumnType, v any) (string, bool) {
if f := viewer.Entry.FormatValue; f != nil {
return f(ct.DatabaseTypeName(), v)
Expand Down
Loading