From 220f69a60173e238a71af2b4a2050c15322c0578 Mon Sep 17 00:00:00 2001 From: dan9186 Date: Mon, 20 Apr 2026 22:54:26 -0700 Subject: [PATCH 1/2] add no color option to be able to copy output without the color codes --- client/client.go | 40 +++++++++++++++++++++++++++++++++------- cmd/root.go | 14 +++++++++++++- 2 files changed, 46 insertions(+), 8 deletions(-) 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/root.go b/cmd/root.go index 4965038..c9bbf66 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -26,12 +26,19 @@ func init() { RootCmd.AddCommand(stash.StashCmd) RootCmd.PersistentFlags().BoolP("verbose", "v", false, "show more verbose output") + RootCmd.PersistentFlags().Bool("no-color", false, "disable color in verbose output") err := viper.BindPFlag("verbose", RootCmd.PersistentFlags().Lookup("verbose")) if err != nil { fmt.Printf("Error setting up: %s\n", err) os.Exit(1) } + + err = viper.BindPFlag("no-color", RootCmd.PersistentFlags().Lookup("no-color")) + if err != nil { + fmt.Printf("Error setting up: %s\n", err) + os.Exit(1) + } } func initEnvs() { @@ -70,7 +77,12 @@ func setupClient(cmd *cobra.Command, args []string) { os.Exit(1) } - clt, err = client.New(c) + var opts []client.Option + if viper.GetBool("no-color") { + opts = append(opts, client.WithNoColor()) + } + + clt, err = client.New(c, opts...) if err != nil { fmt.Printf("Error: %s\n", err) os.Exit(1) From 6425c45097784e1c6d3a0c94cb46735de4076665 Mon Sep 17 00:00:00 2001 From: dan9186 Date: Mon, 20 Apr 2026 22:54:56 -0700 Subject: [PATCH 2/2] more formatting of the auth page --- cmd/auth.go | 156 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 107 insertions(+), 49 deletions(-) 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 — Authorized -
-
-

Authorization complete

-

Align is connected to GitHub. You can close this tab and return to your terminal.

-
+
+ +

GitHub Authorization

+
+
+
+
+ +
+ Authorization complete. Align is connected to GitHub. You can close this tab and return to your terminal. +
+
+ +
+
+ `