Add config flag

This commit is contained in:
Daniel 2024-07-15 22:30:32 -04:00
parent 2db6cae67e
commit c75dd9ec43
3 changed files with 30 additions and 5 deletions

View file

@ -19,8 +19,19 @@ func main() {
rootCmd := cobra.Command{
Use: gordio.AppName,
}
rootCmd.PersistentFlags().StringP("config", "c", "config.yaml", "config file")
cfg, err := config.ReadConfig()
err := rootCmd.ParseFlags(os.Args)
if err != nil {
log.Fatal().Err(err).Msg("parsing flags")
}
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")
}

View file

@ -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

View 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 *;