Skip to content
Snippets Groups Projects
Commit c882e901 authored by Lukas Braun's avatar Lukas Braun
Browse files

implement -dump-config

parent 9bc0c56b
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,9 @@ func (d *duration) UnmarshalJSON(b []byte) (err error) {
return
}
func (d duration) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, d.String())), nil
}
var cfg struct {
......@@ -361,6 +364,7 @@ func main() {
flag_add_user := flag.String("add-user", "", "Add new user to the database. If '-' read name from stdin.")
flag_secret := flag.String("secret", "-", "Secret for the new user. If '-' read from stdin.")
flag_serve := flag.Bool("serve", false, "Start daemon.")
flag_dump_config := flag.Bool("dump-config", false, "Dump the effective config to stdout.")
// also settable in config file
flag.StringVar(&cfg.Db_url, "db-url", ":memory:", "URL used to connect to the database.")
......@@ -390,6 +394,13 @@ func main() {
// default action is to serve, but not if one of the other actions is given
serve_default := true
if *flag_dump_config {
serve_default = false
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", "\t")
err_fatal(enc.Encode(cfg))
}
if *flag_init_db {
serve_default = false
create_table(db)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment