Add config flag
This commit is contained in:
parent
2db6cae67e
commit
c75dd9ec43
3 changed files with 30 additions and 5 deletions
|
@ -19,8 +19,19 @@ func main() {
|
|||
rootCmd := cobra.Command{
|
||||
Use: gordio.AppName,
|
||||
}
|
||||
rootCmd.PersistentFlags().StringP("config", "c", "config.yaml", "config file")
|
||||
|
||||
err := rootCmd.ParseFlags(os.Args)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("parsing flags")
|
||||
}
|
||||
|
||||
cfg, err := config.ReadConfig()
|
||||
cfgPath, err := rootCmd.PersistentFlags().GetString("config")
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("failed parsing config path")
|
||||
}
|
||||
|
||||
cfg, err := config.ReadConfig(config.WithConfigPath(cfgPath))
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Config read failed")
|
||||
}
|
||||
|
|
|
@ -37,10 +37,6 @@ func ReadConfig(opts ...ConfigOption) (*Config, error) {
|
|||
opt(o)
|
||||
}
|
||||
|
||||
if o.configPath == "" {
|
||||
o.configPath = "config.yaml"
|
||||
}
|
||||
|
||||
cfgBytes, err := os.ReadFile(o.configPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
18
sql/postgres/queries/calls.sql
Normal file
18
sql/postgres/queries/calls.sql
Normal file
|
@ -0,0 +1,18 @@
|
|||
-- name: AddCall :one
|
||||
INSERT INTO calls (
|
||||
id,
|
||||
submitter,
|
||||
system,
|
||||
talkgroup,
|
||||
date,
|
||||
audio_name,
|
||||
audio_blob,
|
||||
audio_type,
|
||||
audio_url,
|
||||
frequency_integer,
|
||||
frequencies,
|
||||
patches,
|
||||
tg_label,
|
||||
source
|
||||
) VALUES (gen_random_uuid(), $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
|
||||
RETURNING *;
|
Loading…
Reference in a new issue