aboutsummaryrefslogtreecommitdiff
path: root/internal/commands/init.go
blob: f38ec963c8a2e17ba6e0f6b9948a263c2101d1ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package commands

import (
	"fmt"
	"os"

	"github.com/Fuwn/yae/internal/yae"
	"github.com/urfave/cli/v2"
)

func Init(sources *yae.Sources) func(c *cli.Context) error {
	return func(c *cli.Context) error {
		if _, err := os.Stat(c.String("sources")); err == nil {
			return fmt.Errorf("sources file already exists")
		}

		return sources.Save(c.String("sources"))
	}
}