From df4aa2e08899ebd50fb8f4984c0b216034391adf Mon Sep 17 00:00:00 2001 From: sewn Date: Thu, 8 Feb 2024 21:15:41 +0300 Subject: [PATCH] config: seperate binary validation --- config/config.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/config/config.go b/config/config.go index 773bc4a..9dac978 100644 --- a/config/config.go +++ b/config/config.go @@ -132,27 +132,35 @@ func (b *Binary) LauncherPath() (string, error) { return exec.LookPath(strings.Fields(b.Launcher)[0]) } -func (b *Binary) setup() error { - if err := b.FFlags.SetRenderer(b.Renderer); err != nil { - return err - } - +func (b *Binary) validate() error { if !strings.HasPrefix(b.Renderer, "D3D11") && b.Dxvk { return ErrNeedDXVKRenderer } if b.Launcher != "" { if _, err := b.LauncherPath(); err != nil { - return err + return fmt.Errorf("bad launcher: %s", err) } } if b.WineRoot != "" { if _, err := wine.Wine64(b.WineRoot); err != nil { - return err + return fmt.Errorf("bad wineroot: %s", err) } } + return nil +} + +func (b *Binary) setup() error { + if err := b.validate(); err != nil { + return fmt.Errorf("invalid: %w", err) + } + + if err := b.FFlags.SetRenderer(b.Renderer); err != nil { + return err + } + return b.pickCard() }