-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moving info to --info on the root cmd
- Loading branch information
1 parent
e53611f
commit 26a4b2e
Showing
2 changed files
with
48 additions
and
62 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
"fmt" | ||
"net/http" | ||
"os" | ||
"strings" // Add this import | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
@@ -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]", | ||
|
@@ -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 | ||
} |