Skip to content

Commit

Permalink
Merge pull request #6 from blp1526/api
Browse files Browse the repository at this point in the history
Add Response
  • Loading branch information
blp1526 authored Jul 8, 2017
2 parents 00d7736 + 85ee5fc commit 1276b77
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
11 changes: 9 additions & 2 deletions api/api.go
Original file line number Diff line number Diff line change
@@ -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
}
27 changes: 22 additions & 5 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
@@ -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
}
13 changes: 8 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 1276b77

Please sign in to comment.