48 lines
717 B
Go
48 lines
717 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
)
|
|
|
|
type iostreams struct {
|
|
Err io.Writer
|
|
Out io.Writer
|
|
}
|
|
|
|
type Opts struct {
|
|
ConfigPath string
|
|
IO iostreams
|
|
}
|
|
|
|
func main() {
|
|
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
|
|
}
|