Skip to content

Commit

Permalink
chore: 更新 assert 至 v4
Browse files Browse the repository at this point in the history
  • Loading branch information
caixw committed Feb 28, 2024
1 parent 0c524be commit 5ed5106
Show file tree
Hide file tree
Showing 22 changed files with 68 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
go: ['1.18.x', '1.21.x']
go: ['1.18.x', '1.22.x']

steps:

Expand Down
2 changes: 2 additions & 0 deletions ansi/ansi.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

// Package ansi 输出 ansi 控制码
Expand Down
6 changes: 4 additions & 2 deletions ansi/csi.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

package ansi
Expand All @@ -7,10 +9,10 @@ import (
"strconv"
)

// ResetCode 重置所有状态的 ansi.ESC 状态码
// ResetCode 重置所有状态的 [ESC] 状态码
const ResetCode = 0

// ESC 表示 ansi 转码序列
// ESC 表示 ANSI 转码序列
type ESC string

// F256Color 获取扩展的前景颜色值控制码
Expand Down
4 changes: 3 additions & 1 deletion ansi/csi_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

package ansi
Expand All @@ -6,7 +8,7 @@ import (
"math"
"testing"

"github.com/issue9/assert/v3"
"github.com/issue9/assert/v4"
)

func TestF256Color(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions ansi/writer.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

package ansi
Expand Down
2 changes: 2 additions & 0 deletions ansi/writer_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

package ansi
Expand Down
2 changes: 2 additions & 0 deletions colors/colorize.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

package colors
Expand Down
4 changes: 3 additions & 1 deletion colors/colorize_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

package colors
Expand All @@ -8,7 +10,7 @@ import (
"os"
"testing"

"github.com/issue9/assert/v3"
"github.com/issue9/assert/v4"
)

func TestColorize_Color(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions colors/colors.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

// Package colors 带色彩的控制台文本输出包
Expand Down
4 changes: 3 additions & 1 deletion colors/colors_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

package colors

import (
"testing"

"github.com/issue9/assert/v3"
"github.com/issue9/assert/v4"
)

func TestHEX(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions colors/colors_windows.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

package colors
Expand Down
14 changes: 8 additions & 6 deletions colors/fmt.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

package colors
Expand All @@ -10,32 +12,32 @@ import (
"github.com/issue9/term/v3/ansi"
)

// Fprint 带色彩输出的 fmt.Fprint
// Fprint 带色彩输出的 [fmt.Fprint]
func Fprint(w io.Writer, t Type, foreground, background Color, v ...any) (int, error) {
return fmt.Fprint(w, Sprint(t, foreground, background, v...))
}

// Fprintln 带色彩输出的 fmt.Fprintln
// Fprintln 带色彩输出的 [fmt.Fprintln]
func Fprintln(w io.Writer, t Type, foreground, background Color, v ...any) (int, error) {
return fmt.Fprint(w, Sprintln(t, foreground, background, v...))
}

// Fprintf 带色彩输出的 fmt.Fprintf
// Fprintf 带色彩输出的 [fmt.Fprintf]
func Fprintf(w io.Writer, t Type, foreground, background Color, format string, v ...any) (int, error) {
return fmt.Fprint(w, Sprintf(t, foreground, background, format, v...))
}

// Print 带色彩输出的 fmt.Print
// Print 带色彩输出的 [fmt.Print]
func Print(t Type, foreground, background Color, v ...any) (int, error) {
return Fprint(os.Stdout, t, foreground, background, v...)
}

// Println 带色彩输出的 fmt.Println
// Println 带色彩输出的 [fmt.Println]
func Println(t Type, foreground, background Color, v ...any) (int, error) {
return Fprintln(os.Stdout, t, foreground, background, v...)
}

// Printf 带色彩输出的 fmt.Printf
// Printf 带色彩输出的 [fmt.Printf]
func Printf(t Type, foreground, background Color, format string, v ...any) (int, error) {
return Fprintf(os.Stdout, t, foreground, background, format, v...)
}
Expand Down
7 changes: 4 additions & 3 deletions colors/fmt_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

package colors

import (
"fmt"
"io/ioutil"
"os"
"testing"

"github.com/issue9/assert/v3"
"github.com/issue9/assert/v4"
)

func TestFprint(t *testing.T) {
Expand All @@ -21,7 +22,7 @@ func TestFprint(t *testing.T) {
a.NotError(err)
a.NotError(f.Close())

data, err := ioutil.ReadFile(path)
data, err := os.ReadFile(path)
a.NotError(err).NotNil(data)
a.Contains(string(data), "\033[") // 也包含控制符
}
Expand Down
2 changes: 2 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

// Package term 各平台的终端处理工具
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/issue9/term/v3

require (
github.com/issue9/assert/v3 v3.1.0
github.com/issue9/errwrap v0.3.1
github.com/issue9/sliceutil v0.15.0
golang.org/x/sys v0.15.0
github.com/issue9/assert/v4 v4.1.1
github.com/issue9/errwrap v0.3.2
github.com/issue9/sliceutil v0.15.1
golang.org/x/sys v0.17.0
)

go 1.18
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
github.com/issue9/assert/v3 v3.1.0 h1:oxLFXS7QnBKI4lB31pRoYO96yErkWAJtR7iv+LNjAPg=
github.com/issue9/assert/v3 v3.1.0/go.mod h1:yft/uaskRpwQTyBT3n1zRl91SR1wNlO4fLZHzOa4bdM=
github.com/issue9/errwrap v0.3.1 h1:8g4lYJaGnoiXyZ1oZyH/7zPDGgw5RNiE9Q6ri9kE6Z8=
github.com/issue9/errwrap v0.3.1/go.mod h1:HLR0e5iimd2aJXM9YrThOsRj3/6lMtk77lVp7zyvJ4E=
github.com/issue9/sliceutil v0.15.0 h1:E6Xnl3FY5h0ZGNzyx1VEFAfGdParaq/BkX1QQR0uFwI=
github.com/issue9/sliceutil v0.15.0/go.mod h1:n9meV7AamDhmehOBuV4GrxW3yw7O1cZmLx3Xizg1bps=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
github.com/issue9/assert/v4 v4.1.1 h1:OhPE8SB8n/qZCNGLQa+6MQtr/B3oON0JAVj68k8jJlc=
github.com/issue9/assert/v4 v4.1.1/go.mod h1:v7qDRXi7AsaZZNh8eAK2rkLJg5/clztqQGA1DRv9Lv4=
github.com/issue9/errwrap v0.3.2 h1:7KEme9Pfe75M+sIMcPCn/DV90wjnOcRbO4DXVAHj3Fw=
github.com/issue9/errwrap v0.3.2/go.mod h1:KcCLuUGiffjooLCUjL89r1cyO8/HT/VRcQrneO53N3A=
github.com/issue9/sliceutil v0.15.1 h1:mV1VlQSO5E8sh2ab6pypLg7TdgGZlDb30E8quli01xY=
github.com/issue9/sliceutil v0.15.1/go.mod h1:ldun6sT4/bOJxuMtOXhtc6P7GCwE7L+avV86HNks7qk=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
2 changes: 2 additions & 0 deletions prompt/prompt.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

// Package prompt 简单的终端交互界面
Expand Down
8 changes: 5 additions & 3 deletions prompt/prompt_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

package prompt
Expand All @@ -7,7 +9,7 @@ import (
"io"
"testing"

"github.com/issue9/assert/v3"
"github.com/issue9/assert/v4"

"github.com/issue9/term/v3/colors"
)
Expand All @@ -21,8 +23,8 @@ func TestNew(t *testing.T) {
Equal(p.defaultColor, colors.Red)

p = New('x', new(bytes.Buffer), io.Discard, colors.Red)
a.NotNil(p)
a.Equal(p.delim, 'x')
a.NotNil(p).
Equal(p.delim, 'x')
}

func TestPrompt_String(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions prompt/w.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

package prompt
Expand Down
4 changes: 3 additions & 1 deletion prompt/w_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

package prompt
Expand All @@ -8,7 +10,7 @@ import (
"testing"
"testing/iotest"

"github.com/issue9/assert/v3"
"github.com/issue9/assert/v4"

"github.com/issue9/term/v3/colors"
)
Expand Down
2 changes: 2 additions & 0 deletions term.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

//go:build darwin || dragonfly || freebsd || hurd || linux || netbsd || openbsd
Expand Down
2 changes: 2 additions & 0 deletions term_windows.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-FileCopyrightText: 2014-2024 caixw
//
// SPDX-License-Identifier: MIT

package term
Expand Down

0 comments on commit 5ed5106

Please sign in to comment.