1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

chasquid-util: Add a print-config option

This patch adds a print-config option that will parse a config and print it
(in text protobuf format).

It can be used to validate configurations, and see what the effective
configuration is (that is, including the defaults).
This commit is contained in:
Alberto Bertogli
2016-09-25 20:52:50 +01:00
parent 935494429d
commit ce379dea3e

View File

@@ -14,6 +14,7 @@ import (
"blitiri.com.ar/go/chasquid/internal/userdb"
"github.com/docopt/docopt-go"
"github.com/golang/protobuf/proto"
"golang.org/x/crypto/ssh/terminal"
)
@@ -25,6 +26,7 @@ Usage:
chasquid-util authenticate <db> <username> [--password=<password>]
chasquid-util check-userdb <db>
chasquid-util aliases-resolve <configdir> <address>
chasquid-util print-config <configdir>
`
// Command-line arguments.
@@ -39,6 +41,7 @@ func main() {
"authenticate": Authenticate,
"check-userdb": CheckUserDB,
"aliases-resolve": AliasesResolve,
"print-config": PrintConfig,
}
for cmd, f := range commands {
@@ -196,3 +199,14 @@ func AliasesResolve() {
}
}
// chasquid-util print-config <configdir>
func PrintConfig() {
configDir := args["<configdir>"].(string)
conf, err := config.Load(configDir + "/chasquid.conf")
if err != nil {
Fatalf("Error reading config")
}
fmt.Println(proto.MarshalTextString(conf))
}