ficsit-cli-flake/cmd/profile/mods.go
Vilsol 25f544b8fe
refactor: zerolog -> slog, errors.Wrap -> fmt.Error (#49)
* refactor: zerolog -> slog, errors.Wrap -> fmt.Error

* chore: lint

* fix: correctly handle errors

* fix: use parsed level

* fix: use parsed level, log json to file
2023-12-16 16:19:53 +02:00

36 lines
630 B
Go

package profile
import (
"errors"
"github.com/spf13/cobra"
"github.com/satisfactorymodding/ficsit-cli/cli"
)
func init() {
Cmd.AddCommand(modsCmd)
}
var modsCmd = &cobra.Command{
Use: "mods <profile>",
Short: "List all mods in a profile",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
global, err := cli.InitCLI(false)
if err != nil {
return err
}
profile := global.Profiles.GetProfile(args[0])
if profile == nil {
return errors.New("profile not found")
}
for reference, mod := range profile.Mods {
println(reference, mod.Version)
}
return nil
},
}