From 0a087a3c339f404b6f6c1250f1e5a833c174ce42 Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Fri, 1 Nov 2024 11:04:14 -0400 Subject: [PATCH] feat: move width out of globals --- cmd/docs.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/docs.go b/cmd/docs.go index 2446d168f..a3f117bf0 100644 --- a/cmd/docs.go +++ b/cmd/docs.go @@ -19,8 +19,6 @@ import ( const atmosDocsURL = "https://atmos.tools" -var width uint - // docsCmd opens the Atmos docs and can display component documentation var docsCmd = &cobra.Command{ Use: "docs", @@ -42,6 +40,7 @@ var docsCmd = &cobra.Command{ } // Detect terminal width if width flag is not set + width, _ := cmd.Flags().GetUint("width") if !cmd.Flags().Changed("width") { if term.IsTerminal(int(os.Stdout.Fd())) { w, _, err := term.GetSize(int(os.Stdout.Fd())) @@ -123,5 +122,5 @@ var docsCmd = &cobra.Command{ func init() { RootCmd.AddCommand(docsCmd) - docsCmd.Flags().UintVarP(&width, "width", "w", 0, "Set word-wrap width (0 disables word wrapping). Influences output formatting, particularly for tables.") + docsCmd.Flags().UintP("width", "w", 0, "Set word-wrap width (0 disables word wrapping). Influences output formatting, particularly for tables.") }