Create base structure to allow patching

This commit is contained in:
9seconds
2021-03-10 21:59:01 +03:00
parent ddd3d608fa
commit 299c6478c2
3 changed files with 58 additions and 32 deletions
+37
View File
@@ -0,0 +1,37 @@
package main
import (
"fmt"
"os"
"github.com/9seconds/mtg/v2/mtglib/network"
)
type cli struct {
conf *config
network *network.Network
}
func (c *cli) ReadConfig(path string) error {
filefp, err := os.Open(path)
if err != nil {
return fmt.Errorf("cannot open config file: %w", err)
}
defer filefp.Close()
conf, err := parseConfig(filefp)
if err != nil {
return fmt.Errorf("cannot parse config: %w", err)
}
ntw, err := makeNetwork(conf)
if err != nil {
return fmt.Errorf("cannot build a network: %w", err)
}
c.conf = conf
c.network = ntw
return nil
}