1- // Package main implements the etcd_fdw binary for bidirectional synchronization
1+ // Package main implements the pg_etcd binary for bidirectional synchronization
22// between etcd and PostgreSQL.
33package main
44
@@ -13,18 +13,17 @@ import (
1313 "github.com/jessevdk/go-flags"
1414 "github.com/sirupsen/logrus"
1515
16- "github.com/cybertec-postgresql/etcd_fdw /internal/log"
17- "github.com/cybertec-postgresql/etcd_fdw /internal/sync"
16+ "github.com/cybertec-postgresql/pg_etcd /internal/log"
17+ "github.com/cybertec-postgresql/pg_etcd /internal/sync"
1818)
1919
2020// Config holds the application configuration
2121type Config struct {
22- PostgresDSN string `short:"p" env:"ETCD_FDW_POSTGRES_DSN " long:"postgres-dsn" description:"PostgreSQL connection string"`
23- EtcdDSN string `short:"e" env:"ETCD_FDW_ETCD_DSN " long:"etcd-dsn" description:"etcd connection string"`
24- LogLevel string `short:"l" env:"ETCD_FDW_LOG_LEVEL " long:"log-level" description:"Log level: debug|info|warn|error" default:"info"`
22+ PostgresDSN string `short:"p" env:"pg_etcd_POSTGRES_DSN " long:"postgres-dsn" description:"PostgreSQL connection string"`
23+ EtcdDSN string `short:"e" env:"pg_etcd_ETCD_DSN " long:"etcd-dsn" description:"etcd connection string"`
24+ LogLevel string `short:"l" env:"pg_etcd_LOG_LEVEL " long:"log-level" description:"Log level: debug|info|warn|error" default:"info"`
2525 PollingInterval string `long:"polling-interval" description:"Polling interval for PostgreSQL to etcd sync" default:"1s"`
2626 Version bool `short:"v" long:"version" description:"Show version information"`
27- Help bool
2827}
2928
3029var (
@@ -36,27 +35,20 @@ var (
3635// ParseCLI parses command-line arguments and returns the configuration
3736func ParseCLI (args []string ) (cmdOpts * Config , err error ) {
3837 cmdOpts = new (Config )
39- parser := flags .NewParser (cmdOpts , flags .HelpFlag )
40- parser .SubcommandsOptional = true // if not command specified, start monitoring
41- nonParsedArgs , err := parser .ParseArgs (args ) // parse and execute subcommand if any
38+ parser := flags .NewParser (cmdOpts , flags .Default )
39+ _ , err = parser .ParseArgs (args ) // parse and execute subcommand if any
4240 if err != nil {
43- if flagsErr , ok := err .(* flags.Error ); ok && flagsErr .Type == flags .ErrHelp {
44- cmdOpts .Help = true
45- }
4641 if ! flags .WroteHelp (err ) {
4742 parser .WriteHelp (os .Stdout )
4843 }
4944 return cmdOpts , err
5045 }
51- if len (nonParsedArgs ) > 0 { // we don't expect any non-parsed arguments
52- return cmdOpts , fmt .Errorf ("unknown argument(s): %v" , nonParsedArgs )
53- }
5446 return
5547}
5648
5749// ShowVersion prints version information and exits
5850func ShowVersion () {
59- fmt .Printf ("etcd_fdw version %s\n " , version )
51+ fmt .Printf ("pg_etcd version %s\n " , version )
6052 if commit != "none" && commit != "" {
6153 fmt .Printf ("commit: %s\n " , commit )
6254 }
@@ -85,7 +77,7 @@ func SetupLogging(logLevel string) error {
8577 "version" : version ,
8678 "commit" : commit ,
8779 "pid" : os .Getpid (),
88- }).Info ("etcd_fdw logging initialized" )
80+ }).Info ("pg_etcd logging initialized" )
8981
9082 return nil
9183}
0 commit comments