cmd/stcli: Add config command with pretty printed JSON (#5049)
This commit is contained in:
parent
290dcf0610
commit
9f254df091
|
@ -5,6 +5,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/AudriusButkevicius/cli"
|
"github.com/AudriusButkevicius/cli"
|
||||||
)
|
)
|
||||||
|
@ -23,6 +24,12 @@ func init() {
|
||||||
Requires: &cli.Requires{},
|
Requires: &cli.Requires{},
|
||||||
Action: generalStatus,
|
Action: generalStatus,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "config",
|
||||||
|
Usage: "Configuration",
|
||||||
|
Requires: &cli.Requires{},
|
||||||
|
Action: generalConfiguration,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "restart",
|
Name: "restart",
|
||||||
Usage: "Restart syncthing",
|
Usage: "Restart syncthing",
|
||||||
|
@ -70,6 +77,15 @@ func generalStatus(c *cli.Context) {
|
||||||
fmt.Println("Config in sync")
|
fmt.Println("Config in sync")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func generalConfiguration(c *cli.Context) {
|
||||||
|
response := httpGet(c, "system/config")
|
||||||
|
var jsResponse interface{}
|
||||||
|
json.Unmarshal(responseToBArray(response), &jsResponse)
|
||||||
|
enc := json.NewEncoder(os.Stdout)
|
||||||
|
enc.SetIndent("", " ")
|
||||||
|
enc.Encode(jsResponse)
|
||||||
|
}
|
||||||
|
|
||||||
func generalVersion(c *cli.Context) {
|
func generalVersion(c *cli.Context) {
|
||||||
response := httpGet(c, "system/version")
|
response := httpGet(c, "system/version")
|
||||||
version := make(map[string]interface{})
|
version := make(map[string]interface{})
|
||||||
|
|
Loading…
Reference in New Issue