-
-
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 #154 from hofstadter-io/more-mod-work
hof/mod: add validate, introspection, and psuedoversions
- Loading branch information
Showing
37 changed files
with
721 additions
and
1,627 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
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 verifyLong = `verify integrity of dependencies` | ||
|
||
func VerifyRun(args []string) (err error) { | ||
|
||
err = mod.Verify(flags.RootPflags) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
|
||
return err | ||
} | ||
|
||
var VerifyCmd = &cobra.Command{ | ||
|
||
Use: "verify", | ||
|
||
Short: "verify integrity of dependencies", | ||
|
||
Long: verifyLong, | ||
|
||
PreRun: func(cmd *cobra.Command, args []string) { | ||
|
||
ga.SendCommandPath(cmd.CommandPath()) | ||
|
||
}, | ||
|
||
Run: func(cmd *cobra.Command, args []string) { | ||
var err error | ||
|
||
// Argument Parsing | ||
|
||
err = VerifyRun(args) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
extra := func(cmd *cobra.Command) bool { | ||
|
||
return false | ||
} | ||
|
||
ohelp := VerifyCmd.HelpFunc() | ||
ousage := VerifyCmd.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) | ||
} | ||
VerifyCmd.SetHelpFunc(thelp) | ||
VerifyCmd.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,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 verifyLong = `verify integrity of dependencies` | ||
|
||
func VerifyRun(args []string) (err error) { | ||
|
||
err = mod.Verify(flags.RootPflags) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
|
||
return err | ||
} | ||
|
||
var VerifyCmd = &cobra.Command{ | ||
|
||
Use: "verify", | ||
|
||
Short: "verify integrity of dependencies", | ||
|
||
Long: verifyLong, | ||
|
||
PreRun: func(cmd *cobra.Command, args []string) { | ||
|
||
ga.SendCommandPath(cmd.CommandPath()) | ||
|
||
}, | ||
|
||
Run: func(cmd *cobra.Command, args []string) { | ||
var err error | ||
|
||
// Argument Parsing | ||
|
||
err = VerifyRun(args) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
extra := func(cmd *cobra.Command) bool { | ||
|
||
return false | ||
} | ||
|
||
ohelp := VerifyCmd.HelpFunc() | ||
ousage := VerifyCmd.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) | ||
} | ||
VerifyCmd.SetHelpFunc(thelp) | ||
VerifyCmd.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
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
Oops, something went wrong.