-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from hofstadter-io/mod-revamp
hof/mod: rewrite to focus on CUE
- Loading branch information
Showing
82 changed files
with
3,331 additions
and
1,170 deletions.
There are no files selected for viewing
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package cmdmod | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/hofstadter-io/hof/lib/mod" | ||
|
||
"github.com/hofstadter-io/hof/cmd/hof/flags" | ||
|
||
"github.com/hofstadter-io/hof/cmd/hof/ga" | ||
) | ||
|
||
var tidyLong = `recalculate dependencies and update mod files` | ||
|
||
func TidyRun(args []string) (err error) { | ||
|
||
err = mod.Tidy(flags.RootPflags, flags.ModPflags) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
|
||
return err | ||
} | ||
|
||
var TidyCmd = &cobra.Command{ | ||
|
||
Use: "tidy", | ||
|
||
Short: "recalculate dependencies and update mod files", | ||
|
||
Long: tidyLong, | ||
|
||
PreRun: func(cmd *cobra.Command, args []string) { | ||
|
||
ga.SendCommandPath(cmd.CommandPath()) | ||
|
||
}, | ||
|
||
Run: func(cmd *cobra.Command, args []string) { | ||
var err error | ||
|
||
// Argument Parsing | ||
|
||
err = TidyRun(args) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
extra := func(cmd *cobra.Command) bool { | ||
|
||
return false | ||
} | ||
|
||
ohelp := TidyCmd.HelpFunc() | ||
ousage := TidyCmd.UsageFunc() | ||
help := func(cmd *cobra.Command, args []string) { | ||
if extra(cmd) { | ||
return | ||
} | ||
ohelp(cmd, args) | ||
} | ||
usage := func(cmd *cobra.Command) error { | ||
if extra(cmd) { | ||
return nil | ||
} | ||
return ousage(cmd) | ||
} | ||
|
||
thelp := func(cmd *cobra.Command, args []string) { | ||
ga.SendCommandPath(cmd.CommandPath() + " help") | ||
help(cmd, args) | ||
} | ||
tusage := func(cmd *cobra.Command) error { | ||
ga.SendCommandPath(cmd.CommandPath() + " usage") | ||
return usage(cmd) | ||
} | ||
TidyCmd.SetHelpFunc(thelp) | ||
TidyCmd.SetUsageFunc(tusage) | ||
|
||
} |
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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package flags | ||
|
||
type ModPflagpole struct { | ||
Update bool | ||
} | ||
|
||
var ModPflags ModPflagpole |
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
Oops, something went wrong.