Skip to content

Commit

Permalink
moving info to --info on the root cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
lord-skinner committed Dec 21, 2024
1 parent e53611f commit 26a4b2e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 62 deletions.
62 changes: 0 additions & 62 deletions cmd/info.go

This file was deleted.

48 changes: 48 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"net/http"
"os"
"strings" // Add this import

"github.com/spf13/cobra"
)
Expand All @@ -20,13 +21,18 @@ var rootCmd = &cobra.Command{
checkVersion()
return nil
}
if cmd.Flag("info").Changed {
runInfo(cmd, args)
return nil
}
cmd.Help()
return nil
},
}

func init() {
rootCmd.PersistentFlags().BoolP("version", "v", false, "Print the version number of the CLI tool")
rootCmd.PersistentFlags().BoolP("info", "i", false, "Show Additional Developer Information About dbt-go")

updateCmd = &cobra.Command{
Use: "update [version]",
Expand Down Expand Up @@ -92,3 +98,45 @@ func Execute() {
os.Exit(1)
}
}

func runInfo(cmd *cobra.Command, args []string) error {
asciiArt := `
--------------------------
--------------------------
--------*@@*--------------
------===+@#----===-------
---=#@@@@%@#--+%@@@%%@%=--
--=@@*==+%@#-+@%===#@@=---
--+@*:--:+@*:%@=:-:-@%----
--=%@*++*@@%++@@*++%@%----
---=*%@@%#%%#-=#%%%#@@----
----------------=+=*@#----
---------------#@@@%*-----
--------------------------
--------------------------
`
copyright := "Copyright © 2024"
contact := "Matthew Skinner -- [email protected]"
github := "github.com/cognite-analytics/dbt-go"
width := 80

centeredCopyright := style.CenterText(copyright, width)
centeredContact := style.CenterText(contact, width)
centeredLink := style.CenterText(github, width)
lines := strings.Split(asciiArt, "\n")
centeredLines := make([]string, len(lines))
for i, line := range lines {
centeredLines[i] = style.CenterText(line, width)
}

centeredAsciiArt := strings.Join(centeredLines, "\n")
styledAsciiArt := style.Dg.Render(centeredAsciiArt)

fmt.Printf(`%s
%s
%s
%s
`, styledAsciiArt, centeredCopyright, centeredContact, centeredLink)
return nil
}

0 comments on commit 26a4b2e

Please sign in to comment.