From 4297088e875997dac104aa75422ebaca8c9aa03b Mon Sep 17 00:00:00 2001 From: Tony Worm Date: Tue, 4 Jun 2024 16:57:17 -0400 Subject: [PATCH] cli/mod: add warning about migrating to official implementation --- .hof/shadow/cli/cmd/hof/cmd/mod.go | 20 +++++++++++++++ README.md | 2 +- cmd/hof/cmd/mod.go | 41 ++++++++++++++++++++++++++++++ design/cmds/mod.cue | 1 + 4 files changed, 63 insertions(+), 1 deletion(-) diff --git a/.hof/shadow/cli/cmd/hof/cmd/mod.go b/.hof/shadow/cli/cmd/hof/cmd/mod.go index dd8eba50e..110506120 100644 --- a/.hof/shadow/cli/cmd/hof/cmd/mod.go +++ b/.hof/shadow/cli/cmd/hof/cmd/mod.go @@ -1,6 +1,9 @@ package cmd import ( + "fmt" + "os" + "github.com/spf13/cobra" "github.com/hofstadter-io/hof/cmd/hof/cmd/mod" @@ -98,6 +101,11 @@ hof mod help ` +func ModPersistentPreRun(args []string) (err error) { + + return err +} + var ModCmd = &cobra.Command{ Use: "mod", @@ -109,6 +117,18 @@ var ModCmd = &cobra.Command{ Short: "CUE module dependency management", Long: modLong, + + PersistentPreRun: func(cmd *cobra.Command, args []string) { + var err error + + // Argument Parsing + + err = ModPersistentPreRun(args) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + }, } func init() { diff --git a/README.md b/README.md index 48ec4cd98..749192de2 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,8 @@ The [the-walkthrough](https://docs.hofstadter.io/the-walkthrough/) section shows Join us or ask questions on +- Discord (preferred): https://discord.com/invite/BXwX7n6B8w - Slack: [https://hofstadter-io.slack.com](https://join.slack.com/t/hofstadter-io/shared_invite/zt-e5f90lmq-u695eJur0zE~AG~njNlT1A) -- Discord: https://discord.com/invite/BXwX7n6B8w We also use GitHub issues and discussions. Use which every is easiest for you! diff --git a/cmd/hof/cmd/mod.go b/cmd/hof/cmd/mod.go index dd8eba50e..0f56624a8 100644 --- a/cmd/hof/cmd/mod.go +++ b/cmd/hof/cmd/mod.go @@ -1,6 +1,10 @@ package cmd import ( + "fmt" + "os" + "strconv" + "github.com/spf13/cobra" "github.com/hofstadter-io/hof/cmd/hof/cmd/mod" @@ -98,6 +102,31 @@ hof mod help ` +const modWarning = ` +WARNING: hof will be migrating to CUE modules in 0.7.x +We are doing this to work with the broader ecosystem. +Git based repos will need migration to continue working. + +Set HOF_DISABLE_MOD_WARNING=true to hide this message. +` + +func ModPersistentPreRun(args []string) (err error) { + disable := os.Getenv("HOF_DISABLE_MOD_WARNING") + if disable == "" { + disable = "false" + } + disabled, err := strconv.ParseBool(disable) + if err != nil { + fmt.Fprintln(os.Stderr, err) + } + + if !disabled { + fmt.Fprintln(os.Stderr, modWarning) + } + + return nil +} + var ModCmd = &cobra.Command{ Use: "mod", @@ -109,6 +138,18 @@ var ModCmd = &cobra.Command{ Short: "CUE module dependency management", Long: modLong, + + PersistentPreRun: func(cmd *cobra.Command, args []string) { + var err error + + // Argument Parsing + + err = ModPersistentPreRun(args) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + }, } func init() { diff --git a/design/cmds/mod.cue b/design/cmds/mod.cue index 7164fbbff..28206d8a9 100644 --- a/design/cmds/mod.cue +++ b/design/cmds/mod.cue @@ -20,6 +20,7 @@ ModCommand: schema.Command & { //Topics: #ModTopics //Examples: #ModExamples + PersistentPrerun: true OmitRun: true #body: {