From 19fa501488b4e3bf7cc2ab1d83c0559c739cf674 Mon Sep 17 00:00:00 2001 From: Shingo Kawamura Date: Mon, 10 Jul 2017 01:13:14 +0900 Subject: [PATCH] Add precondition --- README.md | 12 +++++++----- api/api.go | 2 +- cmd/cmd.go | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d68749d..ae2a608 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,16 @@ SAKURA Cloud VNC Opener for MacOS Download a binary from [here](https://github.com/blp1526/scv/releases). -## Usage - +## Precondition -1. Create a config file at `$HOME/scv.json`. +If you use this cli tool, you have to turn on a SAKURA Cloud server power. -1. Write a config file refering to [`scv.sample.json`](scv.sample.json). +## Usage -1. Run below command. +* Create a config file at `$HOME/scv.json`. +* Write a config file refering to [`scv.sample.json`](scv.sample.json). + * This file's server name don't have to match the SAKURA cloud sever name. +* Run below command. ``` # format diff --git a/api/api.go b/api/api.go index 708017b..e28bb89 100644 --- a/api/api.go +++ b/api/api.go @@ -19,7 +19,7 @@ type Body struct { Port string `json:"Port"` } -func Request(body interface{}, zoneName string, serverName string) error { +func Request(body *Body, zoneName string, serverName string) error { scv := &config.Scv{} current, _ := user.Current() dir := filepath.Join(current.HomeDir, "scv.json") diff --git a/cmd/cmd.go b/cmd/cmd.go index 169198d..5559d0f 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -15,12 +15,12 @@ func Run(zoneName string, serverName string) error { return err } - vncPath := vncPath(*body) + vncPath := vncPath(body) logger.Debug(fmt.Sprintf("VNC Path: %s", vncPath)) err = exec.Command("open", vncPath).Run() return err } -func vncPath(body api.Body) string { +func vncPath(body *api.Body) string { return "vnc://:" + body.Password + "@" + body.Host + ":" + body.Port }