ficsit-cli-flake/cmd/apply.go

42 lines
727 B
Go
Raw Normal View History

2022-06-08 20:56:32 +00:00
package cmd
import (
"github.com/spf13/cobra"
2022-10-14 16:11:16 +00:00
"github.com/satisfactorymodding/ficsit-cli/cli"
2022-06-08 20:56:32 +00:00
)
var applyCmd = &cobra.Command{
2022-06-11 01:01:51 +00:00
Use: "apply [installation] ...",
2022-06-08 20:56:32 +00:00
Short: "Apply profiles to all installations",
RunE: func(cmd *cobra.Command, args []string) error {
2022-10-14 16:11:16 +00:00
global, err := cli.InitCLI(false)
2022-06-11 01:01:51 +00:00
if err != nil {
return err
}
for _, installation := range global.Installations.Installations {
if len(args) > 0 {
found := false
for _, installPath := range args {
if installation.Path == installPath {
found = true
break
}
}
if !found {
continue
}
}
if err := installation.Install(global, nil); err != nil {
return err
}
}
2022-06-08 20:56:32 +00:00
return nil
},
}