diff --git a/cmd/uncloud/main.go b/cmd/uncloud/main.go index 4fb9e2db..29aa8be0 100644 --- a/cmd/uncloud/main.go +++ b/cmd/uncloud/main.go @@ -6,6 +6,7 @@ import ( "net/netip" "strings" + "github.com/charmbracelet/lipgloss" "github.com/psviderski/uncloud/cmd/uncloud/caddy" cmdcontext "github.com/psviderski/uncloud/cmd/uncloud/context" "github.com/psviderski/uncloud/cmd/uncloud/dns" @@ -87,6 +88,24 @@ func main() { cmd.PersistentFlags().StringVarP(&opts.context, "context", "c", "", "Name of the cluster context to use (default is the current context). [$UNCLOUD_CONTEXT]") + // Set custom help function to show links to docs and Discord only for the root 'uc' command. + defaultHelpFunc := cmd.HelpFunc() + cmd.SetHelpFunc(func(c *cobra.Command, args []string) { + defaultHelpFunc(c, args) + // Only show links for the root 'uc' command. + if c.Name() == "uc" { + urlStyle := lipgloss.NewStyle(). + Underline(true). + Foreground(lipgloss.Color("12")) // light blue + + fmt.Fprintln(c.OutOrStdout()) + fmt.Fprintf(c.OutOrStdout(), "Learn more about Uncloud: %s\n", + urlStyle.Render("https://uncloud.run/docs")) + fmt.Fprintf(c.OutOrStdout(), "Join our Discord community: %s\n", + urlStyle.Render("https://uncloud.run/discord")) + } + }) + cmd.AddCommand( NewDeployCommand(), NewDocsCommand(),