mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-10 15:18:06 -06:00
[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.
This commit is contained in:
parent
d2f6de0185
commit
65aeeb4442
2 changed files with 147 additions and 11 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue