add apply cli command
This commit is contained in:
parent
cf86f377fa
commit
b0111404aa
1 changed files with 28 additions and 2 deletions
30
cmd/apply.go
30
cmd/apply.go
|
@ -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
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue