Skip to content

Commit

Permalink
cli/mod: add warning about migrating to official implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Worm committed Jun 4, 2024
1 parent 42f4f99 commit 4297088
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
20 changes: 20 additions & 0 deletions .hof/shadow/cli/cmd/hof/cmd/mod.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package cmd

import (
"fmt"
"os"

"github.com/spf13/cobra"

"github.com/hofstadter-io/hof/cmd/hof/cmd/mod"
Expand Down Expand Up @@ -98,6 +101,11 @@ hof mod help
`

func ModPersistentPreRun(args []string) (err error) {

return err
}

var ModCmd = &cobra.Command{

Use: "mod",
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down
41 changes: 41 additions & 0 deletions cmd/hof/cmd/mod.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package cmd

import (
"fmt"
"os"
"strconv"

"github.com/spf13/cobra"

"github.com/hofstadter-io/hof/cmd/hof/cmd/mod"
Expand Down Expand Up @@ -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",
Expand All @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions design/cmds/mod.cue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ModCommand: schema.Command & {
//Topics: #ModTopics
//Examples: #ModExamples

PersistentPrerun: true
OmitRun: true

#body: {
Expand Down

0 comments on commit 4297088

Please sign in to comment.