diff options
Diffstat (limited to 'cmd/ponzu/add.go')
-rw-r--r-- | cmd/ponzu/add.go | 28 |
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) +} |