mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-03 07:12:27 +00:00
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 (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/AudriusButkevicius/cli"
|
||||
)
|
||||
@ -23,6 +24,12 @@ func init() {
|
||||
Requires: &cli.Requires{},
|
||||
Action: generalStatus,
|
||||
},
|
||||
{
|
||||
Name: "config",
|
||||
Usage: "Configuration",
|
||||
Requires: &cli.Requires{},
|
||||
Action: generalConfiguration,
|
||||
},
|
||||
{
|
||||
Name: "restart",
|
||||
Usage: "Restart syncthing",
|
||||
@ -70,6 +77,15 @@ func generalStatus(c *cli.Context) {
|
||||
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) {
|
||||
response := httpGet(c, "system/version")
|
||||
version := make(map[string]interface{})
|
||||
|
Loading…
Reference in New Issue
Block a user