Move exampleCommand to its own project

This commit is contained in:
Ian Howell 2019-05-17 11:15:39 -05:00
parent 863f195066
commit c89bd79342
4 changed files with 5 additions and 21 deletions

View File

@ -1,19 +0,0 @@
package cmd
import (
"fmt"
"io"
"github.com/spf13/cobra"
)
func NewExampleCommand(out io.Writer, args []string) *cobra.Command {
exampleCommand := &cobra.Command{
Use: "example",
Short: "an example command",
Run: func(cmd *cobra.Command, args []string) {
fmt.Fprintln(out, "Hello world!")
},
}
return exampleCommand
}

View File

@ -4,6 +4,7 @@ import (
"io"
"github.com/spf13/cobra"
"github.com/ian-howell/exampleplugin"
)
// builtinPlugins are the plugins that are built and maintained by the
@ -15,5 +16,5 @@ var builtinPlugins = []func(io.Writer, []string) *cobra.Command{
// externalPlugins are external. The function to create a command should be
// placed here
var externalPlugins = []func(io.Writer, []string) *cobra.Command{
NewExampleCommand, // This is an example and shouldn't be enabled in production builds
exampleplugin.NewExampleCommand, // This is an example and shouldn't be enabled in production builds
}

2
go.mod
View File

@ -11,11 +11,11 @@ require (
github.com/golangci/golangci-lint v1.16.0
github.com/google/gofuzz v1.0.0 // indirect
github.com/googleapis/gnostic v0.2.0 // indirect
github.com/ian-howell/exampleplugin v0.0.0-20190517155332-c2802087ee41
github.com/imdario/mergo v0.3.7 // indirect
github.com/json-iterator/go v1.1.6 // indirect
github.com/shuLhan/go-bindata v3.4.0+incompatible // indirect
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.3 // indirect
golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd // indirect
golang.org/x/net v0.0.0-20190420063019-afa5a82059c6 // indirect
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a // indirect

2
go.sum
View File

@ -117,6 +117,8 @@ github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce h1:xdsDDbiBDQTKASoGE
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ian-howell/exampleplugin v0.0.0-20190517155332-c2802087ee41 h1:7id5OLQ6anGo6Vx4MnvSqhPfFm0Q5Rq2vwZqGzD7w5Q=
github.com/ian-howell/exampleplugin v0.0.0-20190517155332-c2802087ee41/go.mod h1:8kk62mP18Zi2+BzITEc0n+QKWQLT9xN+5GBRwETQYEk=
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=