Files
tendermint/scripts/confix/confix.go
M. J. Fromberger 18b5a500da Extract a library from the confix command-line tool. (#9012)
Pull out the library functionality from scripts/confix and move it to
internal/libs/confix. Replace scripts/confix with a simple stub that has the
same command-line API, but uses the library instead.

Related:

- Move and update unit tests.
- Move scripts/confix/condiff to scripts/condiff.
- Update test data for v34, v35, and v36.
- Update reference diffs.
- Update testdata README.
2022-07-15 07:29:34 -07:00

55 lines
1.4 KiB
Go

// Program confix applies changes to a Tendermint TOML configuration file, to
// update configurations created with an older version of Tendermint to a
// compatible format for a newer version.
package main
import (
"context"
"flag"
"fmt"
"log"
"os"
"path/filepath"
"github.com/tendermint/tendermint/internal/libs/confix"
)
func init() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, `Usage: %[1]s -config <src> [-out <dst>]
Modify the contents of the specified -config TOML file to update the names,
locations, and values of configuration settings to the current configuration
layout. The output is written to -out, or to stdout.
It is valid to set -config and -out to the same path. In that case, the file will
be modified in-place. In case of any error in updating the file, no output is
written.
Options:
`, filepath.Base(os.Args[0]))
flag.PrintDefaults()
}
}
var (
configPath = flag.String("config", "", "Config file path (required)")
outPath = flag.String("out", "", "Output file path (default stdout)")
doVerbose = flag.Bool("v", false, "Log changes to stderr")
)
func main() {
flag.Parse()
if *configPath == "" {
log.Fatal("You must specify a non-empty -config path")
}
ctx := context.Background()
if *doVerbose {
ctx = confix.WithLogWriter(ctx, os.Stderr)
}
if err := confix.Upgrade(ctx, *configPath, *outPath); err != nil {
log.Fatalf("Upgrading config: %v", err)
}
}