build(deps): bump github.com/gookit/config/v2 from 2.2.6 to 2.2.7

Bumps [github.com/gookit/config/v2](https://github.com/gookit/config) from 2.2.6 to 2.2.7.
- [Release notes](https://github.com/gookit/config/releases)
- [Commits](https://github.com/gookit/config/compare/v2.2.6...v2.2.7)

---
updated-dependencies:
- dependency-name: github.com/gookit/config/v2
  dependency-version: 2.2.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2025-08-15 14:15:33 +00:00
committed by GitHub
parent 28770fe20d
commit 89a7d171ee
180 changed files with 7454 additions and 9644 deletions
+8 -26
View File
@@ -3,6 +3,7 @@ package cmdline
import (
"strings"
"github.com/gookit/goutil/internal/comfunc"
"github.com/gookit/goutil/strutil"
)
@@ -24,6 +25,12 @@ func NewBuilder(binFile string, args ...string) *LineBuilder {
return b
}
// ResetGet value, will reset after get.
func (b *LineBuilder) ResetGet() string {
defer b.Reset()
return b.String()
}
// AddArg to builder
func (b *LineBuilder) AddArg(arg string) {
_, _ = b.WriteString(arg)
@@ -51,35 +58,10 @@ func (b *LineBuilder) AddAny(args ...any) {
// WriteString arg string to the builder, will auto quote special string.
// refer strconv.Quote()
func (b *LineBuilder) WriteString(a string) (int, error) {
var quote byte
if pos := strings.IndexByte(a, '"'); pos > -1 {
quote = '\''
// fix: a = `--pretty=format:"one two three"`
if pos > 0 && a[len(a)-1] == '"' {
quote = 0
}
} else if pos := strings.IndexByte(a, '\''); pos > -1 {
quote = '"'
// fix: a = "--pretty=format:'one two three'"
if pos > 0 && a[len(a)-1] == '\'' {
quote = 0
}
} else if a == "" || strings.ContainsRune(a, ' ') {
quote = '"'
}
// add sep on not-first write.
if b.Len() != 0 {
_ = b.WriteByte(' ')
}
// no quote char OR not need quote
if quote == 0 {
return b.Builder.WriteString(a)
}
_ = b.WriteByte(quote) // add start quote
n, err := b.Builder.WriteString(a)
_ = b.WriteByte(quote) // add end quote
return n, err
return b.Builder.WriteString(comfunc.ShellQuote(a))
}
+6 -3
View File
@@ -1,12 +1,15 @@
// Package cmdline provide quick build and parse cmd line string.
package cmdline
import "github.com/gookit/goutil/internal/comfunc"
// LineBuild build command line string by given args.
func LineBuild(binFile string, args []string) string {
return NewBuilder(binFile, args...).String()
}
// ParseLine input command line text. alias of the StringToOSArgs()
func ParseLine(line string) []string {
return NewParser(line).Parse()
}
func ParseLine(line string) []string { return NewParser(line).Parse() }
// Quote string in shell command env
func Quote(s string) string { return comfunc.ShellQuote(s) }