@@ -7,18 +7,6 @@ import (
77 flags "github.com/jessevdk/go-flags"
88)
99
10- // ConnectionOpts specifies the database connection options
11- type ConnectionOpts struct {
12- Host string `short:"h" long:"host" description:"PostgreSQL host" default:"localhost" env:"PGTT_PGHOST"`
13- Port int `short:"p" long:"port" description:"PostgreSQL port" default:"5432" env:"PGTT_PGPORT"`
14- DBName string `short:"d" long:"dbname" description:"PostgreSQL database name" default:"timetable" env:"PGTT_PGDATABASE"`
15- User string `short:"u" long:"user" description:"PostgreSQL user" default:"scheduler" env:"PGTT_PGUSER"`
16- Password string `long:"password" description:"PostgreSQL user password" env:"PGTT_PGPASSWORD"`
17- SSLMode string `long:"sslmode" default:"disable" description:"Connection SSL mode" env:"PGTT_PGSSLMODE" choice:"disable" choice:"require"`
18- PgURL string `long:"pgurl" description:"PostgreSQL connection URL" env:"PGTT_URL"`
19- Timeout int `long:"timeout" description:"PostgreSQL connection timeout" env:"PGTT_TIMEOUT" default:"90"`
20- }
21-
2210// LoggingOpts specifies the logging configuration
2311type LoggingOpts struct {
2412 LogLevel string `long:"log-level" mapstructure:"log-level" description:"Verbosity level for stdout and log file" choice:"debug" choice:"info" choice:"error" default:"info"`
@@ -54,16 +42,16 @@ type RestAPIOpts struct {
5442
5543// CmdOptions holds command line options passed
5644type CmdOptions struct {
57- ClientName string `short:"c" long:"clientname" description:"Unique name for application instance" env:"PGTT_CLIENTNAME"`
58- Config string `long:"config" description:"YAML configuration file"`
59- Connection ConnectionOpts `group:"Connection" mapstructure :"Connection"`
60- Logging LoggingOpts `group:"Logging" mapstructure:"Logging"`
61- Start StartOpts `group:"Start" mapstructure:"Start"`
62- Resource ResourceOpts `group:"Resource" mapstructure:"Resource"`
63- RESTApi RestAPIOpts `group:"REST" mapstructure:"REST"`
64- NoProgramTasks bool `long:"no-program-tasks" mapstructure:"no-program-tasks" description:"Disable executing of PROGRAM tasks" env:"PGTT_NOPROGRAMTASKS"`
65- NoHelpMessage bool `long:"no-help" mapstructure:"no-help" hidden:"system use"`
66- Version bool `short:"v" long:"version" mapstructure:"version" description:"Output detailed version information" env:"PGTT_VERSION"`
45+ ClientName string `short:"c" long:"clientname" description:"Unique name for application instance" env:"PGTT_CLIENTNAME"`
46+ Config string `long:"config" description:"YAML configuration file"`
47+ ConnStr string `long:"connstr" description :"Connection string" env:"PGTT_CONNSTR "`
48+ Logging LoggingOpts `group:"Logging" mapstructure:"Logging"`
49+ Start StartOpts `group:"Start" mapstructure:"Start"`
50+ Resource ResourceOpts `group:"Resource" mapstructure:"Resource"`
51+ RESTApi RestAPIOpts `group:"REST" mapstructure:"REST"`
52+ NoProgramTasks bool `long:"no-program-tasks" mapstructure:"no-program-tasks" description:"Disable executing of PROGRAM tasks" env:"PGTT_NOPROGRAMTASKS"`
53+ NoHelpMessage bool `long:"no-help" mapstructure:"no-help" hidden:"system use"`
54+ Version bool `short:"v" long:"version" mapstructure:"version" description:"Output detailed version information" env:"PGTT_VERSION"`
6755}
6856
6957// Verbose returns true if the debug log is enabled
@@ -102,8 +90,8 @@ func Parse(writer io.Writer) (*flags.Parser, error) {
10290 }
10391 }
10492 //non-option arguments
105- if len (nonOptionArgs ) > 0 && cmdOpts .Connection . PgURL == "" {
106- cmdOpts .Connection . PgURL = nonOptionArgs [0 ]
93+ if len (nonOptionArgs ) > 0 && cmdOpts .ConnStr == "" {
94+ cmdOpts .ConnStr = nonOptionArgs [0 ]
10795 }
10896 return parser , nil
10997}
0 commit comments