summaryrefslogtreecommitdiff
path: root/cmd/ponzu/add.go
diff options
context:
space:
mode:
authorMartin Treusch von Buttlar <martin.tvb@vitraum.de>2017-05-15 22:39:14 +0200
committerMartin Treusch von Buttlar <martin.tvb@vitraum.de>2017-05-15 22:39:14 +0200
commit4c54cc43537fd15cc459030cb792f8171bcd0fd7 (patch)
tree9e81500281ea4a33685bbf77f7c5ad2bbb3636e2 /cmd/ponzu/add.go
parent0cf8aa550a3da63cb1509678bf5add0d73925546 (diff)
add cobra commands
Diffstat (limited to 'cmd/ponzu/add.go')
-rw-r--r--cmd/ponzu/add.go28
1 files changed, 26 insertions, 2 deletions
diff --git a/cmd/ponzu/add.go b/cmd/ponzu/add.go
index 05d6f16..c1242db 100644
--- a/cmd/ponzu/add.go
+++ b/cmd/ponzu/add.go
@@ -8,15 +8,35 @@ import (
"os/exec"
"path/filepath"
"strings"
+
+ "github.com/spf13/cobra"
)
+var addCmd = &cobra.Command{
+ Use: "add <repo>",
+ Short: "Downloads addon from specified import path",
+ Long: `Downloads addon from specified import path to $GOPATH/src and copys it to the
+current project's ./addons directory. Must be called from within a
+Ponzu project directory.
+
+Example:
+$ ponzu add github.com/bosssauce/fbscheduler`,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ // expecting two args, add and the go gettable package uri
+ if len(args) < 1 {
+ return errors.New("repo not given")
+ }
+
+ return getAddon(args[0])
+ },
+}
+
// use `go get` to download addon and add to $GOPATH/src, useful
// for IDE auto-import and code completion, then copy entire directory
// tree to project's ./addons folder
-func getAddon(args []string) error {
+func getAddon(addonPath string) error {
var cmdOptions []string
- var addonPath = args[1]
// Go get
cmdOptions = append(cmdOptions, "get", addonPath)
@@ -165,3 +185,7 @@ func copyFileContents(src, dst string) (err error) {
func addError(err error) error {
return errors.New("Ponzu add failed. " + "\n" + err.Error())
}
+
+func init() {
+ rootCmd.AddCommand(addCmd)
+}