diff --git a/Makefile b/Makefile index fcdc67d..544a94e 100644 --- a/Makefile +++ b/Makefile @@ -21,15 +21,15 @@ VERSION:=$(shell git describe --tags 2>$(NUL) || echo v0.0.0) GOOPT:=-ldflags "-s -w -X github.com/hymkor/sqlbless.Version=$(VERSION)" EXE=$(shell $(GO) env GOEXE) -all: +build: $(GO) fmt ./... - $(SET) "CGO_ENABLED=0" && $(GO) build $(GOOPT) && $(GO) build -C "$(CURDIR)/cmd/sqlbless" -o "$(CURDIR)/$(NAME)$(EXE)" $(GOOPT) + $(SET) "CGO_ENABLED=0" && $(GO) build -C "$(CURDIR)/cmd/sqlbless" -o "$(CURDIR)" $(GOOPT) test: $(GO) test -v ./... _dist: - $(MAKE) all + $(SET) "CGO_ENABLED=0" && $(GO) build -C "$(CURDIR)/cmd/sqlbless" -o "$(CURDIR)" $(GOOPT) zip -9 $(NAME)-$(VERSION)-$(GOOS)-$(GOARCH).zip $(NAME)$(EXE) dist: @@ -42,22 +42,17 @@ clean: $(DEL) *.zip $(NAME)$(EXE) manifest: - make-scoop-manifest *-windows-*.zip > $(NAME).json + $(GO) run github.com/hymkor/make-scoop-manifest@master -all *-windows-*.zip > $(NAME).json release: - pwsh -Command "latest-notes.ps1" | gh release create -d --notes-file - -t $(VERSION) $(VERSION) $(wildcard $(NAME)-$(VERSION)-*.zip) - -get: - $(GO) get -u - $(GO) get golang.org/x/sys@v0.30.0 -# $(GO) get golang.org/x/text@v0.22.0 - $(GO) get golang.org/x/term@v0.29.0 - $(GO) get golang.org/x/exp@v0.0.0-20240531132922-fd00a4e0eefc - $(GO) mod tidy -# cd "$(CURDIR)/cmd/sqlbless" && $(GO) get -u && $(GO) mod tidy + $(GO) run github.com/hymkor/latest-notes@latest | gh release create -d --notes-file - -t $(VERSION) $(VERSION) $(wildcard $(NAME)-$(VERSION)-*.zip) docs: - minipage -outline-in-sidebar -readme-to-index README.md > docs/index.html - minipage -outline-in-sidebar -readme-to-index README_ja.md > docs/index_ja.html + go run github.com/hymkor/minipage@latest -outline-in-sidebar -readme-to-index README.md > docs/index.html + go run github.com/hymkor/minipage@latest -outline-in-sidebar -readme-to-index README_ja.md > docs/index_ja.html + +readme: + go run github.com/hymkor/example-into-readme@latest + go run github.com/hymkor/example-into-readme@latest -target README_ja.md .PHONY: all test dist _dist clean manifest release docs diff --git a/README.md b/README.md index 31fd274..aeeb669 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ SQL-Bless =========== - + [![Go Test](https://github.com/hymkor/sqlbless/actions/workflows/go.yml/badge.svg)](https://github.com/hymkor/sqlbless/actions/workflows/go.yml) [![License](https://img.shields.io/badge/License-MIT-red)](https://github.com/hymkor/sqlbless/blob/master/LICENSE) [![Go Reference](https://pkg.go.dev/badge/github.com/hymkor/sqlbless.svg)](https://pkg.go.dev/github.com/hymkor/sqlbless) +[![GitHub](https://img.shields.io/badge/github-repo-blue?logo=github)](https://github.com/hymkor/sqlbless) **<English>** / [<Japanese>](./README_ja.md) @@ -95,11 +96,16 @@ Supported commands - `EDIT [tablename [WHERE conditions...]]` - Start an [editor][csvi] to modify the selected records of the table. - In the editor, these keys are bound. - - | Key | Bindings - |-------|----------------------------- - |`x`,`d`| Set NULL to the current cell - |`q` | Quit editor with confirmation to apply or discard changes + + | Key | Action | + | --- | --- | + | `r` | Replace cell value (using built-in readline) | + | `o` | Append a new row | + | `dd`, `dr` | **Delete the current row** | + | `x` | **Set the current cell to NULL** | + | `q` | Quit editor (with apply/discard confirmation) | + + **Note:** The `D` key is disabled to prevent accidental execution due to terminal escape sequence delays. Please use `dd` or `dr` instead. - Because the EDIT statement automatically generates SQL from data changed in the editor, it may not be able to properly represent SQL data for special types specific to individual databases. If you find it, we would appreciate it if you could [contact us](https://github.com/hymkor/sqlbless/issues/new). - `HOST command-line` diff --git a/README_ja.md b/README_ja.md index b2e50a0..61a9df4 100644 --- a/README_ja.md +++ b/README_ja.md @@ -1,10 +1,11 @@ SQL-Bless ========= - + [![Go Test](https://github.com/hymkor/sqlbless/actions/workflows/go.yml/badge.svg)](https://github.com/hymkor/sqlbless/actions/workflows/go.yml) [![License](https://img.shields.io/badge/License-MIT-red)](https://github.com/hymkor/sqlbless/blob/master/LICENSE) [![Go Reference](https://pkg.go.dev/badge/github.com/hymkor/sqlbless.svg)](https://pkg.go.dev/github.com/hymkor/sqlbless) +[![GitHub](https://img.shields.io/badge/github-repo-blue?logo=github)](https://github.com/hymkor/sqlbless) [<English>](./README.md) / **<Japanese>** @@ -94,10 +95,16 @@ SQL-Bless は、そうした現場での教訓から生まれた、安全で再 - 選択したテーブルのレコードを修正するため [エディタ][csvi] を起動します - エディタ中では以下のキーが拡張されます - | Key | Bindings - |-------|----------------------------- - |`x`,`d`| セルに NULL をセットする - |`q` | 変更を適用するかを確認してから終了 + | キー | 操作内容 | + | --- | --- | + | `r` | カレントセルを組み込みの readline で編集する | + | `o` | 新しい行を末尾に追加する | + | `dd`, `dr` | カレント行を削除する | + | `x` | カレントセルに NULL を設定する | + | `q` | エディタを終了する(変更の適用または破棄を確認) | + + **※** ターミナルのエスケープシーケンス遅延による誤作動を防ぐため、`D` キーによる削除は無効化された。行の削除には `dd` または `dr` を使用のこと + - EDIT文は、エディターでの変更データから自動で SQL を生成する都合、個々のデータベース固有の特殊な型向けの SQL データをうまく表現できない場合があります。見つかりましたら、[ご連絡](https://github.com/hymkor/sqlbless/issues/new)いただけるとたすかります。 - `HOST command-line` diff --git a/commands.go b/commands.go index 54b3902..d2e838a 100644 --- a/commands.go +++ b/commands.go @@ -119,13 +119,13 @@ func doDescTables(ctx context.Context, ss *session, commandIn commandIn) error { var name string handler := func(e *csvi.KeyEventArgs) (*csvi.CommandResult, error) { - if e.CursorRow.Index() == 0 { + if e.CurrentRow().Index() == 0 { return &csvi.CommandResult{}, nil } header := e.Front() for i, c := range header.Cell { if strings.EqualFold(c.Text(), ss.Dialect.TableNameField) { - name = e.CursorRow.Cell[i].Text() + name = e.CurrentRow().Cell[i].Text() return &csvi.CommandResult{Quit: true}, nil } } diff --git a/docs/index.html b/docs/index.html index 9a49822..6fbac77 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1140,11 +1140,12 @@

SQL-Bless

- +

Go Test License -Go Reference

- +Go Reference +GitHub

+

<English> / <Japanese>

SQL-Bless is a command-line database client similar to SQL*Plus, supporting multiple database systems.

It was designed with reliability and transparency in mind. @@ -1306,20 +1307,33 @@

Supported commands

Key -Bindings +Action -x,d -Set NULL to the current cell +r +Replace cell value (using built-in readline) + + +o +Append a new row + + +dd, dr +Delete the current row + + +x +Set the current cell to NULL q -Quit editor with confirmation to apply or discard changes +Quit editor (with apply/discard confirmation) +

Note: The D key is disabled to prevent accidental execution due to terminal escape sequence delays. Please use dd or dr instead.

  • Because the EDIT statement automatically generates SQL from data changed in the editor, it may not be able to properly represent SQL data for special types specific to individual databases. If you find it, we would appreciate it if you could contact us.

    diff --git a/docs/index_ja.html b/docs/index_ja.html index 90bbe19..7ce478b 100644 --- a/docs/index_ja.html +++ b/docs/index_ja.html @@ -1140,11 +1140,12 @@

    SQL-Bless

    - +

    Go Test License -Go Reference

    - +Go Reference +GitHub

    +

    <English> / <Japanese>

    SQL-Bless は、SQL*Plus に着想を得た、複数のデータベースエンジンに対応するコマンドライン用 SQL クライアントです。

    SQL-Bless は「安全性と再現性」を最優先に設計されています。 @@ -1303,21 +1304,34 @@

    ご連絡いただけるとたすかります。

    diff --git a/go.mod b/go.mod index 6b0922e..4ed0333 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/glebarez/go-sqlite v1.22.0 github.com/go-sql-driver/mysql v1.8.1 - github.com/hymkor/csvi v1.21.1 + github.com/hymkor/csvi v1.22.0 github.com/hymkor/go-multiline-ny v0.22.4 github.com/hymkor/go-shellcommand v0.0.2 github.com/hymkor/struct2flag v0.0.4 @@ -13,7 +13,7 @@ require ( github.com/mattn/go-colorable v0.1.14 github.com/mattn/go-isatty v0.0.20 github.com/microsoft/go-mssqldb v1.7.2 - github.com/nyaosorg/go-box/v3 v3.0.0 + github.com/nyaosorg/go-box/v3 v3.1.1 github.com/nyaosorg/go-readline-ny v1.14.1 github.com/nyaosorg/go-ttyadapter v0.3.0 github.com/sijms/go-ora/v2 v2.8.22 @@ -21,8 +21,7 @@ require ( require ( filippo.io/edwards25519 v1.1.0 // indirect - github.com/clipperhouse/stringish v0.1.1 // indirect - github.com/clipperhouse/uax29/v2 v2.3.0 // indirect + github.com/clipperhouse/uax29/v2 v2.6.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect diff --git a/go.sum b/go.sum index 32312d5..10b6eec 100644 --- a/go.sum +++ b/go.sum @@ -6,10 +6,8 @@ github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 h1:6oNBlSdi1QqM1PNW7FPA6xO github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.1 h1:MyVTgWR8qd/Jw1Le0NZebGBUCLbtak3bJ3z1OlqZBpw= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.0.0 h1:D3occbWoio4EBLkbkevetNMAVX197GkzbUMtqjGWn80= github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 h1:DzHpqpoJVaCgOUdVHxE8QB52S6NiVdDQvGlny1qvPqA= -github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs= -github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA= -github.com/clipperhouse/uax29/v2 v2.3.0 h1:SNdx9DVUqMoBuBoW3iLOj4FQv3dN5mDtuqwuhIGpJy4= -github.com/clipperhouse/uax29/v2 v2.3.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g= +github.com/clipperhouse/uax29/v2 v2.6.0 h1:z0cDbUV+aPASdFb2/ndFnS9ts/WNXgTNNGFoKXuhpos= +github.com/clipperhouse/uax29/v2 v2.6.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= @@ -25,8 +23,8 @@ github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EO github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd h1:gbpYu9NMq8jhDVbvlGkMFWCjLFlqqEZjEmObmhUy6Vo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hymkor/csvi v1.21.1 h1:8rgQgH0mGTeuzabk7cN53g87LwoR/uMQIAmIEqIk0bo= -github.com/hymkor/csvi v1.21.1/go.mod h1:zm4EcSzlGiiCtPWq77a+L3Q5IpJufIEX0q4iIGKXZhs= +github.com/hymkor/csvi v1.22.0 h1:fvUDS81s5LReepPjSI+/PWVmWlnxAYyL6SUILOOooO8= +github.com/hymkor/csvi v1.22.0/go.mod h1:zm4EcSzlGiiCtPWq77a+L3Q5IpJufIEX0q4iIGKXZhs= github.com/hymkor/go-multiline-ny v0.22.4 h1:Ag2rkBpDnr3jp+AHe1CuXSOQ4AQ8D0+gBNVf+BAX+/0= github.com/hymkor/go-multiline-ny v0.22.4/go.mod h1:v2lqQooHVAO53WICAIbgTn74bQtzsg4tFn29d+7JPwY= github.com/hymkor/go-shellcommand v0.0.2 h1:6+XG2h/9DGk5i3Oh4rU48z/nsPWx4Sp73s6OpryQtyw= @@ -50,8 +48,8 @@ github.com/microsoft/go-mssqldb v1.7.2 h1:CHkFJiObW7ItKTJfHo1QX7QBBD1iV+mn1eOyRP github.com/microsoft/go-mssqldb v1.7.2/go.mod h1:kOvZKUdrhhFQmxLZqbwUV0rHkNkZpthMITIb2Ko1IoA= github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= -github.com/nyaosorg/go-box/v3 v3.0.0 h1:W5qfScEkKBoD68gbP/lwfWlvcTRB0rwXkhL+9iC62xI= -github.com/nyaosorg/go-box/v3 v3.0.0/go.mod h1:70GsE9mIh7JKVCxt71q3jEijO6C9YJmOZqWpPa9w+GY= +github.com/nyaosorg/go-box/v3 v3.1.1 h1:iTWE0MOTlD52yEySfhdN6nonX7Uagkn985xQZM6sCyI= +github.com/nyaosorg/go-box/v3 v3.1.1/go.mod h1:kuRLL+x9n7kqIAiSZRXgNxP+HJVelsCKplo2TQSnWIo= github.com/nyaosorg/go-inline-animation v0.3.0 h1:LrOHowED2PrXEUWGagL1bLR+XTXD06EoWnLRAAn0PWc= github.com/nyaosorg/go-inline-animation v0.3.0/go.mod h1:GLb7BXeLMuA12LMN3c8l69GQcmlAxit3oZRKILztOsU= github.com/nyaosorg/go-readline-ny v1.14.1 h1:bWyXpR6jRaCXysx4bnioxk36+YjQ6dypHKMjHnzIXdk= diff --git a/release_note_en.md b/release_note_en.md index 22ee554..3946ccf 100644 --- a/release_note_en.md +++ b/release_note_en.md @@ -2,6 +2,20 @@ Release notes (English) ======================= ( **English** / [Japanese](release_note_ja.md) ) +v0.27.4 +------- +Feb 14, 2026 + +- `edit` statement: Restore row deletion commands (`dd`, `dr`): + Fixed a keybinding conflict that rendered row deletion unavailable. The `d` key has been unassigned from the "Set Null" function to restore the `dd` and `dr` commands, following specification changes in Csvi. Field Null assignment remains available via the `x` key. (#35) +- `edit` statement: Prevent creation of empty lines at the end of the editable CSV content. ([csvi#79]) +- (internal changes) Stop using deprecated fields: `csvi.KeyEventArgs.CursorRow` and `CursorCol` ([csvi#80],#38) +- `edit` statement: Quit immediately on `q` without a prompt if there are no changes.([csvi#81],#39) + +[csvi#79]: https://github.com/hymkor/csvi/pull/79 +[csvi#80]: https://github.com/hymkor/csvi/pull/80 +[csvi#81]: https://github.com/hymkor/csvi/pull/81 + v0.27.3 ------- Feb 6, 2026 diff --git a/release_note_ja.md b/release_note_ja.md index 78daac4..be9f92f 100644 --- a/release_note_ja.md +++ b/release_note_ja.md @@ -2,6 +2,20 @@ Release notes (Japanese) ======================== ( [English](release_note_en.md) / **Japanese** ) +v0.27.4 +------- +Feb 14, 2026 + +- `edit`文: 行削除コマンド(`dd`, `dr`)の復旧 + レコードの削除操作(`dd`, `dr`)を再び利用可能にした。以前のバージョンでは、Null設定機能を `d` キーにも割り当てていたため、Csvi側の仕様変更(`D` の廃止)に伴い、行削除が実行できない状態になっていた。今回、`d` へのNull設定機能を解除することでこの競合を解消した。※Null設定機能は、引き続き `x` キーで利用可能。 (#35) +- `edit`文: 編集対象の CSV データ末尾に空行が生成されないようにした。([csvi#79]) +- (内部修正) 廃止予定のフィールド `csvi.KeyEventArgs.CursorRow` と `CursorCol` 使わないようにした ([csvi#80],#38) +- `edit`文: 変更がない場合は `q` で確認なしに終了するようにした。([csvi#81],#39) + +[csvi#79]: https://github.com/hymkor/csvi/pull/79 +[csvi#80]: https://github.com/hymkor/csvi/pull/80 +[csvi#81]: https://github.com/hymkor/csvi/pull/81 + v0.27.3 ------- Feb 6, 2026 diff --git a/spread/view.go b/spread/view.go index 9bccce4..fce7c7e 100644 --- a/spread/view.go +++ b/spread/view.go @@ -59,22 +59,27 @@ func (viewer *Viewer) edit(title string, validate func(*csvi.CellValidatedEvent) applyChange := false setNull := func(e *csvi.KeyEventArgs) (*csvi.CommandResult, error) { - if e.CursorRow.Index() < viewer.HeaderLines { + if e.CurrentRow().Index() < viewer.HeaderLines { return &csvi.CommandResult{}, nil } ce := &csvi.CellValidatedEvent{ Text: viewer.Null, - Row: e.CursorRow.Index(), - Col: e.CursorCol, + Row: e.CurrentRow().Index(), + Col: e.CurrentCol(), } if _, err := validate(ce); err != nil { return &csvi.CommandResult{Message: err.Error()}, nil } - e.CursorRow.Replace(e.CursorCol, viewer.Null, &uncsv.Mode{Comma: viewer.Comma}) + e.CurrentRow().Replace(e.CurrentCol(), viewer.Null, &uncsv.Mode{Comma: viewer.Comma}) return &csvi.CommandResult{}, nil } quit := func(app *csvi.KeyEventArgs) (*csvi.CommandResult, error) { + if !app.IsDirty() { + io.WriteString(app, "\n") + return &csvi.CommandResult{Quit: true}, nil + } + ch, err := app.MessageAndGetKey(`"Y": Save&Exit "N": Discard&Exit : Cancel(edit)`) if err != nil { return nil, err @@ -95,7 +100,6 @@ func (viewer *Viewer) edit(title string, validate func(*csvi.CellValidatedEvent) keymap := map[string]func(*csvi.KeyEventArgs) (*csvi.CommandResult, error){ "q": quit, "x": setNull, - "d": setNull, } for _, p := range viewer.OnEvents { keymap[p.Key] = p.Handler diff --git a/sqlbless.json b/sqlbless.json index 0ebecca..7258e89 100644 --- a/sqlbless.json +++ b/sqlbless.json @@ -1,16 +1,16 @@ { - "version": "0.27.3", + "version": "0.27.4", "description": "A safety-oriented terminal SQL client", "homepage": "https://github.com/hymkor/sqlbless", "license": "MIT License", "architecture": { "32bit": { - "url": "https://github.com/hymkor/sqlbless/releases/download/v0.27.3/sqlbless-v0.27.3-windows-386.zip", - "hash": "e12ae26143fcfc6c54ad98cd9b3b7e0e830999fe1dfb4124946d746530d4a002" + "url": "https://github.com/hymkor/sqlbless/releases/download/v0.27.4/sqlbless-v0.27.4-windows-386.zip", + "hash": "058859b5fc430b55c268616f9a1ede2916881448de3ee56eeae0132ddffa50b6" }, "64bit": { - "url": "https://github.com/hymkor/sqlbless/releases/download/v0.27.3/sqlbless-v0.27.3-windows-amd64.zip", - "hash": "702b1cdb20c86430f2b4743188c18821904d20c681f4be87f0b9bb2e3c6a0d7d" + "url": "https://github.com/hymkor/sqlbless/releases/download/v0.27.4/sqlbless-v0.27.4-windows-amd64.zip", + "hash": "8213a0ac3d96a2b2c111d75af6fdf61758e1703d9f882b0d11544d1d6a893343" } }, "bin": "sqlbless.exe",