forked from tmtk75/kii-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.go
43 lines (39 loc) · 958 Bytes
/
app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package kiicli
import (
"fmt"
"github.com/tmtk75/cli"
"strings"
)
func PrintAppInfo() {
p := Profile()
path := fmt.Sprintf("/apps/%s/", p.AppId)
headers := p.HttpHeadersWithAuthorization("")
body := HttpGet(path, headers).Bytes()
fmt.Printf("%s\n", string(body))
}
func SetAppParam(name string, value string) {
p := Profile()
path := fmt.Sprintf("/apps/%s/configuration/parameters/%s", p.AppId, name)
headers := p.HttpHeadersWithAuthorization("text/plain")
body := HttpPut(path, headers, strings.NewReader(value)).Bytes()
fmt.Printf("%s\n", string(body))
}
var AppCommands = []cli.Command{
{
Name: "config",
Usage: "Print config of app",
Action: func(c *cli.Context) {
PrintAppInfo()
},
},
{
Name: "set-param",
Usage: "set an app param",
Args: "<paramname> <paramvalue>",
Action: func(c *cli.Context) {
name, _ := c.ArgFor("paramname")
value, _ := c.ArgFor("paramvalue")
SetAppParam(name, value)
},
},
}