diff --git a/api/api.go b/api/api.go index 96aca00..0e3aba3 100644 --- a/api/api.go +++ b/api/api.go @@ -1,4 +1,11 @@ package api -// func Request(zone string, id string) (*Response, err) { -// } +type Response struct { + Host string `json:Host` + Password string `json:"Password"` + Port string `json:Port` +} + +func Request(zoneName string, ServerId string) (*Response, err) { + return response, err +} diff --git a/cmd/cmd.go b/cmd/cmd.go index 6686527..3f97033 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -1,9 +1,26 @@ package cmd -import "os/exec" +import ( + "fmt" + "os/exec" -func Run(arg string) error { - argument := "foo" - err := exec.Command("open", argument).Run() - return err + "github.com/blp1526/scv/api" +) + +func Run(zoneName string, serverName string) error { + apiResponse, err := api.Request(zoneName, serverId) + vncPath = cmd.vncPath(apiResponse) + err := exec.Command("open", vncPath).Run() + + if err != nil { + fmt.Println(err) + } +} + +func vncPath(apiResponse) string { + password = "" + host = "" + port = "" + + return "// vnc://:%s@%s:%s" + password + host + port } diff --git a/main.go b/main.go index bb86550..b7c41a1 100644 --- a/main.go +++ b/main.go @@ -16,17 +16,20 @@ import ( ) func main() { + version := "0.0.1" + expectedArgsSize := 2 + argsSize := len(os.Args) - 1 if argsSize == 0 { - fmt.Println("scv version 0.0.1") - } else if argsSize == 1 { - err := cmd.Run("foo") + fmt.Printf("scv version %s\n", version) + } else if argsSize == 2 { + err := cmd.Run(os.Args[1], os.Args[2]) if err != nil { fmt.Println(err) } } else { - msg := "ArgumentError: wrong number of arguments (given %d, expected 1)\n" - fmt.Printf(msg, argsSize) + msg := "fatal: Wrong number of arguments (given %d, expected %d)\n" + fmt.Printf(msg, argsSize, expectedArgsSize) os.Exit(1) } }