Configure line endings (windows).

This commit is contained in:
Nuno Cruces 2021-05-07 13:41:48 +01:00
parent 40c8a6e6cd
commit e03bf87915
4 changed files with 8 additions and 15 deletions

View file

@ -82,6 +82,7 @@ var (
noCancel bool noCancel bool
// Windows specific options // Windows specific options
unixeol bool
cygpath bool cygpath bool
wslpath bool wslpath bool
) )
@ -100,6 +101,9 @@ func main() {
validateFlags() validateFlags()
opts := loadFlags() opts := loadFlags()
zenutil.Command = true zenutil.Command = true
if unixeol {
zenutil.LineBreak = "\n"
}
if zenutil.Timeout > 0 { if zenutil.Timeout > 0 {
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(zenutil.Timeout)*time.Second) ctx, cancel := context.WithTimeout(context.Background(), time.Duration(zenutil.Timeout)*time.Second)
opts = append(opts, zenity.Context(ctx)) opts = append(opts, zenity.Context(ctx))
@ -218,6 +222,7 @@ func setupFlags() {
// Windows specific options // Windows specific options
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
flag.BoolVar(&unixeol, "unixeol", false, "Use Unix line endings (Windows only)")
flag.BoolVar(&cygpath, "cygpath", false, "Use cygpath for path translation (Windows only)") flag.BoolVar(&cygpath, "cygpath", false, "Use cygpath for path translation (Windows only)")
flag.BoolVar(&wslpath, "wslpath", false, "Use wslpath for path translation (Windows only)") flag.BoolVar(&wslpath, "wslpath", false, "Use wslpath for path translation (Windows only)")
} }

View file

@ -1,13 +1,9 @@
package zenutil package zenutil
// These are internal.
const (
LineBreak = "\n"
)
// These are internal. // These are internal.
var ( var (
Command bool Command bool
Timeout int Timeout int
LineBreak = "\n"
Separator = "\x00" Separator = "\x00"
) )

View file

@ -3,14 +3,10 @@
// Package zenutil is internal. DO NOT USE. // Package zenutil is internal. DO NOT USE.
package zenutil package zenutil
// These are internal.
const (
LineBreak = "\n"
)
// These are internal. // These are internal.
var ( var (
Command bool Command bool
Timeout int Timeout int
LineBreak = "\n"
Separator = "\x1e" Separator = "\x1e"
) )

View file

@ -1,13 +1,9 @@
package zenutil package zenutil
// These are internal.
const (
LineBreak = "\r\n"
)
// These are internal. // These are internal.
var ( var (
Command bool Command bool
Timeout int Timeout int
Separator string Separator string
LineBreak = "\r\n"
) )