From b5e8b5355616f74e109370742ca309ba67a63dcf Mon Sep 17 00:00:00 2001 From: floriankammermann Date: Sun, 3 Dec 2017 23:58:04 +0100 Subject: [PATCH] add possibility to execute arbitrary request --- cmd/request.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 cmd/request.go diff --git a/cmd/request.go b/cmd/request.go new file mode 100644 index 0000000..6b77438 --- /dev/null +++ b/cmd/request.go @@ -0,0 +1,34 @@ +package cmd + +import ( + "fmt" + "github.com/spf13/cobra" + "github.com/floriankammermann/vcloud-cli/vcdapi" + "github.com/spf13/viper" +) + +var path string + +var requestCmd = &cobra.Command{ + Use: "request", + Short: "execute requests", + Long: "execute requests", + Run: func(cmd *cobra.Command, args []string) { + + if len(path) > 0 { + url := viper.GetString("url") + user := viper.GetString("user") + password := viper.GetString("password") + org := viper.GetString("org") + vcdapi.GetAuthToken(url, user, password, org) + vcdapi.ExecRequest(url, path, nil) + } else { + fmt.Println("you have to provide the path") + } + }, +} + +func init() { + requestCmd.Flags().StringVarP(&path, "path", "n", "", "url to request") + RootCmd.AddCommand(requestCmd) +}