summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorLibravatar Daenney <daenney@users.noreply.github.com>2023-03-04 21:56:50 +0100
committerLibravatar GitHub <noreply@github.com>2023-03-04 20:56:50 +0000
commit65aeeb44427c1fe9d6a6d41829b7e02d5f1896ec (patch)
treee8f68fa035ccf1833c9377588eaf3bed024e1ddd /cmd
parent[feature] Allow loading TLS certs from disk (#1586) (diff)
downloadgotosocial-65aeeb44427c1fe9d6a6d41829b7e02d5f1896ec.tar.xz
[chore] Print human readable config (#1589)
This changes the config action to print the config in a more human readable format, indented by 4 spaces and with newlines. Thanks to this, we can now reasonably construct some JSON in the envparsing shell script, without needing utilities like jd. It does assume cat is available in order to not change the shebang to bash. With the expected JSON now being one key per line it should make it much easier for multiple PRs that change something around config not to collide in merge conflicts.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gotosocial/action/debug/config/config.go15
1 files changed, 5 insertions, 10 deletions
diff --git a/cmd/gotosocial/action/debug/config/config.go b/cmd/gotosocial/action/debug/config/config.go
index 6c697cbff..24f15e79f 100644
--- a/cmd/gotosocial/action/debug/config/config.go
+++ b/cmd/gotosocial/action/debug/config/config.go
@@ -21,7 +21,7 @@ package config
import (
"context"
"encoding/json"
- "fmt"
+ "os"
"github.com/superseriousbusiness/gotosocial/cmd/gotosocial/action"
"github.com/superseriousbusiness/gotosocial/internal/config"
@@ -39,13 +39,8 @@ var Config action.GTSAction = func(ctx context.Context) (err error) {
return err
}
- // Marshal map to JSON
- b, err := json.Marshal(raw)
- if err != nil {
- return err
- }
-
- // Print to stdout
- fmt.Printf("%s\n", b)
- return nil
+ enc := json.NewEncoder(os.Stdout)
+ enc.SetIndent("", " ")
+ err = enc.Encode(raw)
+ return err
}