add apply cli command

This commit is contained in:
Vilsol 2022-06-11 04:01:51 +03:00
parent cf86f377fa
commit b0111404aa

View file

@ -1,14 +1,40 @@
package cmd package cmd
import ( import (
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var applyCmd = &cobra.Command{ var applyCmd = &cobra.Command{
Use: "apply", Use: "apply [installation] ...",
Short: "Apply profiles to all installations", Short: "Apply profiles to all installations",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
// TODO global, err := cli.InitCLI()
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
}
}
return nil return nil
}, },
} }