bbj2/server/cmd/main.go

48 lines
717 B
Go
Raw Normal View History

2022-04-11 02:32:02 +00:00
package main
2022-04-11 03:45:33 +00:00
import (
"flag"
"fmt"
"io"
"os"
)
type iostreams struct {
Err io.Writer
Out io.Writer
}
type Opts struct {
ConfigPath string
IO iostreams
}
2022-04-11 02:32:02 +00:00
func main() {
2022-04-11 03:45:33 +00:00
var configFlag = flag.String("config", "config.yml", "A path to a config file.")
flag.Parse()
opts := Opts{
ConfigPath: *configFlag,
IO: iostreams{
Err: os.Stderr,
Out: os.Stdout,
},
}
err := _main(opts)
if err != nil {
fmt.Fprintf(os.Stderr, "failed: %s", err)
}
}
func _main(opts Opts) error {
cfg, err := parseConfig(opts.ConfigPath)
if err != nil {
fmt.Fprintf(os.Stderr, "could not read config file '%s'", opts.ConfigPath)
os.Exit(1)
}
fmt.Printf("DBG %#v\n", cfg.InstanceName)
return nil
}