diff --git a/client/client.go b/client/client.go index f561338..5d55591 100644 --- a/client/client.go +++ b/client/client.go @@ -34,8 +34,27 @@ type Client struct { ghHTTPSAuth *sshgit.Password } +// Option configures a Client. +type Option func(*clientOptions) + +type clientOptions struct { + noColor bool +} + +// WithNoColor disables ANSI color codes in verbose output. +func WithNoColor() Option { + return func(o *clientOptions) { + o.noColor = true + } +} + // New constructs a Client from cfg, initialising SSH auth, HTTPS auth, the GitHub API client, and rate limiter. -func New(cfg *config.Config) (*Client, error) { +func New(cfg *config.Config, opts ...Option) (*Client, error) { + co := &clientOptions{} + for _, o := range opts { + o(co) + } + pool := trust.New() certs, err := pool.CACerts() @@ -109,12 +128,19 @@ func New(cfg *config.Config) (*Client, error) { } } - t := &scribe.Theme{ - Describe: scribe.NoopDecorator, - Print: scribe.NoopDecorator, - Error: func(err error) string { - return fmt.Sprintf("%s %s\n", color.RedFg("Error:"), err) - }, + var t *scribe.Theme + if co.noColor { + t = scribe.DefaultTheme + } else { + t = &scribe.Theme{ + Describe: func(s string) string { + return color.CyanFg(s) + }, + Print: scribe.NoopDecorator, + Error: func(err error) string { + return fmt.Sprintf("%s %s\n", color.RedFg("Error:"), err) + }, + } } scrb, err := scribe.NewScribe(os.Stdout, t) diff --git a/cmd/auth.go b/cmd/auth.go index ea01c58..49a7a37 100644 --- a/cmd/auth.go +++ b/cmd/auth.go @@ -172,73 +172,131 @@ func authHandler(ctx context.Context, conf *oauth2.Config, state string, token c
- +Align is connected to GitHub. You can close this tab and return to your terminal.
-