Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: escape sequences on windows powershell #234

Merged
merged 4 commits into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/golang/mock v1.5.0
github.com/golang/snappy v0.0.3 // indirect
github.com/google/go-cmp v0.5.5
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apparently we missed a go mod vendor from previous PRs

github.com/klauspost/compress v1.11.9 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/lestrrat-go/jwx v1.1.4
Expand All @@ -33,7 +34,7 @@ require (
github.com/zalando/go-keyring v0.1.1
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 // indirect
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43
golang.org/x/sys v0.0.0-20210305023407-0d6cb8bd5a4b // indirect
golang.org/x/sys v0.0.0-20210305023407-0d6cb8bd5a4b
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d
golang.org/x/text v0.3.5 // indirect
gopkg.in/auth0.v5 v5.11.0
Expand Down
7 changes: 7 additions & 0 deletions internal/ansi/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// +build !windows

package ansi

// InitConsole initializes any platform-specific aspect of the terminal.
// This method will run for all except Windows.
func InitConsole() {}
21 changes: 21 additions & 0 deletions internal/ansi/init_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ansi

import (
"golang.org/x/sys/windows"
)

// IinitConsole configures the standard output and error streams
// on Windows systems. This is necessary to enable colored and ANSI output.
// This is the Windows implementation of ansi/init.go.
func InitConsole() {
setWindowsConsoleMode(windows.Stdout, windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING)
setWindowsConsoleMode(windows.Stderr, windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING)
}

func setWindowsConsoleMode(handle windows.Handle, flags uint32) {
var mode uint32
// set the console mode if not already there:
if err := windows.GetConsoleMode(handle, &mode); err == nil {
_ = windows.SetConsoleMode(handle, mode|flags)
}
}
6 changes: 6 additions & 0 deletions internal/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"

"github.com/auth0/auth0-cli/internal/ansi"
"github.com/auth0/auth0-cli/internal/buildinfo"
"github.com/auth0/auth0-cli/internal/display"
"github.com/auth0/auth0-cli/internal/instrumentation"
Expand Down Expand Up @@ -107,6 +108,11 @@ func Execute() {
}
}()

// platform specific terminal initialization:
// this should run for all commands,
// for most of the architechtures there's no requirements:
jfatta marked this conversation as resolved.
Show resolved Hide resolved
ansi.InitConsole()

if err := rootCmd.ExecuteContext(context.TODO()); err != nil {
cli.renderer.Heading("error")
cli.renderer.Errorf(err.Error())
Expand Down
1 change: 1 addition & 0 deletions vendor/modules.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.