Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Commit

Permalink
some cool updates from hofmod-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
verdverm committed May 8, 2020
1 parent b86fe84 commit 958e0a5
Show file tree
Hide file tree
Showing 34 changed files with 538 additions and 49 deletions.
14 changes: 7 additions & 7 deletions .hof/Cli/cmd/mvs/.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ builds:

ldflags:
- -s -w
- -X github.com/hofstadter-io/mvs/cmd/mvs/cmd.Version={{.Version}}
- -X github.com/hofstadter-io/mvs/cmd/mvs/cmd.Commit={{.FullCommit}}
- -X github.com/hofstadter-io/mvs/cmd/mvs/cmd.BuildDate={{.Date}}
- -X github.com/hofstadter-io/mvs/cmd/mvs/cmd.GoVersion=go1.14
- -X github.com/hofstadter-io/mvs/cmd/mvs/cmd.BuildOS={{.Os}}
- -X github.com/hofstadter-io/mvs/cmd/mvs/cmd.BuildArch={{.Arch}}
- -X github.com/hofstadter-io/mvs/cmd/mvs/cmd.BuildArm={{.Arm}}
- -X github.com/hofstadter-io/mvs/cmd/mvs/verinfo.Version={{.Version}}
- -X github.com/hofstadter-io/mvs/cmd/mvs/verinfo.Commit={{.FullCommit}}
- -X github.com/hofstadter-io/mvs/cmd/mvs/verinfo.BuildDate={{.Date}}
- -X github.com/hofstadter-io/mvs/cmd/mvs/verinfo.GoVersion=go1.14
- -X github.com/hofstadter-io/mvs/cmd/mvs/verinfo.BuildOS={{.Os}}
- -X github.com/hofstadter-io/mvs/cmd/mvs/verinfo.BuildArch={{.Arch}}
- -X github.com/hofstadter-io/mvs/cmd/mvs/verinfo.BuildArm={{.Arm}}

env:
- CGO_ENABLED=0
Expand Down
12 changes: 12 additions & 0 deletions .hof/Cli/cmd/mvs/cmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/mvs/lib"

"github.com/hofstadter-io/mvs/cmd/mvs/ga"
)

var convertLong = `convert another package system to MVS.`
Expand All @@ -30,6 +34,14 @@ var ConvertCmd = &cobra.Command{

Long: convertLong,

PreRun: func(cmd *cobra.Command, args []string) {

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)

},

Run: func(cmd *cobra.Command, args []string) {
var err error

Expand Down
12 changes: 12 additions & 0 deletions .hof/Cli/cmd/mvs/cmd/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/mvs/lib"

"github.com/hofstadter-io/mvs/cmd/mvs/ga"
)

var graphLong = `print module requirement graph`
Expand All @@ -30,6 +34,14 @@ var GraphCmd = &cobra.Command{

Long: graphLong,

PreRun: func(cmd *cobra.Command, args []string) {

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)

},

Run: func(cmd *cobra.Command, args []string) {
var err error

Expand Down
12 changes: 12 additions & 0 deletions .hof/Cli/cmd/mvs/cmd/hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/mvs/lib"

"github.com/hofstadter-io/mvs/cmd/mvs/ga"
)

var hackLong = `dev command`
Expand All @@ -32,6 +36,14 @@ var HackCmd = &cobra.Command{

Long: hackLong,

PreRun: func(cmd *cobra.Command, args []string) {

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)

},

Run: func(cmd *cobra.Command, args []string) {
var err error

Expand Down
12 changes: 12 additions & 0 deletions .hof/Cli/cmd/mvs/cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/mvs/lib"

"github.com/hofstadter-io/mvs/cmd/mvs/ga"
)

var infoLong = ` print info about languages and modders known to mvs
Expand All @@ -33,6 +37,14 @@ var InfoCmd = &cobra.Command{

Long: infoLong,

PreRun: func(cmd *cobra.Command, args []string) {

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)

},

Run: func(cmd *cobra.Command, args []string) {
var err error

Expand Down
12 changes: 12 additions & 0 deletions .hof/Cli/cmd/mvs/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/mvs/lib"

"github.com/hofstadter-io/mvs/cmd/mvs/ga"
)

var initLong = `initialize a new module in the current directory`
Expand All @@ -30,6 +34,14 @@ var InitCmd = &cobra.Command{

Long: initLong,

PreRun: func(cmd *cobra.Command, args []string) {

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)

},

Run: func(cmd *cobra.Command, args []string) {
var err error

Expand Down
21 changes: 21 additions & 0 deletions .hof/Cli/cmd/mvs/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/mvs/lib"

"github.com/hofstadter-io/mvs/cmd/mvs/ga"
)

var mvsLong = `MVS is a polyglot dependency management tool based on go mods.
Expand Down Expand Up @@ -51,9 +55,26 @@ var RootCmd = &cobra.Command{
os.Exit(1)
}
},

PreRun: func(cmd *cobra.Command, args []string) {

ga.SendGaEvent("root", strings.Join(args, "/"), 0)

},
}

func init() {

hf := RootCmd.HelpFunc()
f := func(cmd *cobra.Command, args []string) {
if RootCmd.Name() == cmd.Name() {
as := strings.Join(args, "/")
ga.SendGaEvent("root/help", as, 0)
}
hf(cmd, args)
}
RootCmd.SetHelpFunc(f)

cobra.OnInitialize(initConfig)
RootCmd.AddCommand(InfoCmd)
RootCmd.AddCommand(ConvertCmd)
Expand Down
12 changes: 12 additions & 0 deletions .hof/Cli/cmd/mvs/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/mvs/lib"

"github.com/hofstadter-io/mvs/cmd/mvs/ga"
)

var statusLong = `print module dependencies status`
Expand All @@ -30,6 +34,14 @@ var StatusCmd = &cobra.Command{

Long: statusLong,

PreRun: func(cmd *cobra.Command, args []string) {

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)

},

Run: func(cmd *cobra.Command, args []string) {
var err error

Expand Down
12 changes: 12 additions & 0 deletions .hof/Cli/cmd/mvs/cmd/tidy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/mvs/lib"

"github.com/hofstadter-io/mvs/cmd/mvs/ga"
)

var tidyLong = `add missinad and remove unused modules`
Expand All @@ -30,6 +34,14 @@ var TidyCmd = &cobra.Command{

Long: tidyLong,

PreRun: func(cmd *cobra.Command, args []string) {

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)

},

Run: func(cmd *cobra.Command, args []string) {
var err error

Expand Down
12 changes: 12 additions & 0 deletions .hof/Cli/cmd/mvs/cmd/vendor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/mvs/lib"

"github.com/hofstadter-io/mvs/cmd/mvs/ga"
)

var vendorLong = `make a vendored copy of dependencies`
Expand All @@ -30,6 +34,14 @@ var VendorCmd = &cobra.Command{

Long: vendorLong,

PreRun: func(cmd *cobra.Command, args []string) {

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)

},

Run: func(cmd *cobra.Command, args []string) {
var err error

Expand Down
12 changes: 12 additions & 0 deletions .hof/Cli/cmd/mvs/cmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import (
"fmt"
"os"

"strings"

"github.com/spf13/cobra"

"github.com/hofstadter-io/mvs/lib"

"github.com/hofstadter-io/mvs/cmd/mvs/ga"
)

var verifyLong = `verify dependencies have expected content`
Expand All @@ -30,6 +34,14 @@ var VerifyCmd = &cobra.Command{

Long: verifyLong,

PreRun: func(cmd *cobra.Command, args []string) {

cs := strings.Fields(cmd.CommandPath())
c := strings.Join(cs[1:], "/")
ga.SendGaEvent(c, strings.Join(args, "/"), 0)

},

Run: func(cmd *cobra.Command, args []string) {
var err error

Expand Down
28 changes: 13 additions & 15 deletions .hof/Cli/cmd/mvs/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@ package cmd

import (
"fmt"
"os"
"path/filepath"

"github.com/spf13/cobra"
)

var (
Version = "Local"
Commit = "Dirty"

BuildDate = "Unknown"
GoVersion = "Unknown"
BuildOS = "Unknown"
BuildArch = "Unknown"
"github.com/hofstadter-io/mvs/cmd/mvs/verinfo"
)

const versionMessage = `
Expand All @@ -40,14 +34,18 @@ var VersionCmd = &cobra.Command{
Long: VersionLong,

Run: func(cmd *cobra.Command, args []string) {

s, e := os.UserConfigDir()
fmt.Printf("mvs ConfigDir %q %v\n", filepath.Join(s, "mvs"), e)

fmt.Printf(
versionMessage,
Version,
Commit,
BuildDate,
GoVersion,
BuildOS,
BuildArch,
verinfo.Version,
verinfo.Commit,
verinfo.BuildDate,
verinfo.GoVersion,
verinfo.BuildOS,
verinfo.BuildArch,
)
},
}
Expand Down
Loading

0 comments on commit 958e0a5

Please sign in to comment.