add cli commands, docs, readme

This commit is contained in:
Vilsol 2022-06-08 23:56:32 +03:00
parent 1daf6e9610
commit e01db90b0b
43 changed files with 1213 additions and 48 deletions

View file

@ -6,11 +6,11 @@ before:
- go mod tidy
builds:
- env:
- id: with-upx
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
@ -20,9 +20,25 @@ builds:
- 386
goarm:
- 7
hooks:
post: 'upx {{ .Path }}'
- id: without-upx
env:
- CGO_ENABLED=0
goos:
- windows
goarch:
- amd64
- arm
- arm64
- 386
goarm:
- 7
universal_binaries:
- replace: true
ids:
- with-upx
archives:
- format: binary
@ -35,6 +51,7 @@ nfpms:
maintainer: Satisfactory Modding Team <support@ficsit.app>
description: CLI tool for Ficsit (Satisfactory Modding)
license: GNU General Public License v3.0
file_name_template: "{{ .PackageName }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}"
formats:
- apk
- deb

59
README.md Normal file
View file

@ -0,0 +1,59 @@
# ficsit-cli [![push](https://github.com/Vilsol/ficsit-cli/actions/workflows/push.yaml/badge.svg)](https://github.com/Vilsol/ficsit-cli/actions/workflows/push.yaml) ![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/vilsol/ficsit-cli) ![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/vilsol/ficsit-cli) [![GitHub license](https://img.shields.io/github/license/Vilsol/ficsit-cli)](https://github.com/Vilsol/ficsit-cli/blob/master/LICENSE) ![GitHub all releases](https://img.shields.io/github/downloads/vilsol/ficsit-cli/total)
A CLI tool for managing mods for the game Satisfactory
## Installation
### Windows
Download the appropriate `.exe` for your CPU architecture.
* [AMD64 (64-bit)](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_windows_amd64.exe)
* [386 (32-bit)](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_windows_386.exe)
* [ARM64 (64-bit ARM)](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_windows_arm64.exe)
* [ARMv7 (32-bit ARM)](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_windows_armv7.exe)
### Linux
#### Arch
A package is published to AUR under the name [`ficsit-cli-bin`](https://aur.archlinux.org/packages/ficsit-cli-bin)
```shell
yay -S ficsit-cli-bin
```
#### Debian (inc. Ubuntu, Mint, PopOS!, etc)
Download the appropriate `.deb` for your CPU architecture.
* [AMD64 (64-bit)](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_linux_amd64.deb)
* [386 (32-bit)](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_linux_386.deb)
* [ARM64 (64-bit ARM)](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_linux_arm64.deb)
* [ARMv7 (32-bit ARM)](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_linux_armv7.deb)
* [PowerPC64](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_linux_ppc64le.deb)
#### Fedora
Download the appropriate `.rpm` for your CPU architecture.
* [AMD64 (64-bit)](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_linux_amd64.rpm)
* [386 (32-bit)](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_linux_386.rpm)
* [ARM64 (64-bit ARM)](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_linux_arm64.rpm)
* [ARMv7 (32-bit ARM)](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_linux_armv7.rpm)
* [PowerPC64](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_linux_ppc64le.rpm)
#### Alpine
Download the appropriate `.apk` for your CPU architecture.
* [AMD64 (64-bit)](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_linux_amd64.apk)
* [386 (32-bit)](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_linux_386.apk)
* [ARM64 (64-bit ARM)](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_linux_arm64.apk)
* [ARMv7 (32-bit ARM)](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_linux_armv7.apk)
* [PowerPC64](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_linux_ppc64le.apk)
### macOS
Download the "all" build [here](https://github.com/Vilsol/ficsit-cli/releases/latest/download/ficsit_darwin_all).

View file

@ -218,7 +218,7 @@ func (p *Profiles) GetProfile(name string) *Profile {
return p.Profiles[name]
}
func (p *Profiles) RenameProfile(oldName string, newName string) error {
func (p *Profiles) RenameProfile(ctx *GlobalContext, oldName string, newName string) error {
if _, ok := p.Profiles[newName]; ok {
return fmt.Errorf("profile with name %s already exists", newName)
}
@ -235,6 +235,12 @@ func (p *Profiles) RenameProfile(oldName string, newName string) error {
p.SelectedProfile = newName
}
for _, installation := range ctx.Installations.Installations {
if installation.Profile == oldName {
installation.Profile = newName
}
}
return nil
}

14
cmd/apply.go Normal file
View file

@ -0,0 +1,14 @@
package cmd
import (
"github.com/spf13/cobra"
)
var applyCmd = &cobra.Command{
Use: "apply",
Short: "Apply profiles to all installations",
RunE: func(cmd *cobra.Command, args []string) error {
// TODO
return nil
},
}

View file

@ -1,22 +1,25 @@
package cmd
import (
"github.com/rs/zerolog/log"
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/satisfactorymodding/ficsit-cli/tea"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
func init() {
rootCmd.AddCommand(cliCmd)
}
var cliCmd = &cobra.Command{
Use: "cli",
Short: "Start interactive CLI",
Short: "Start interactive CLI (default)",
RunE: func(cmd *cobra.Command, args []string) error {
log.Info().
Str("version", viper.GetString("version")).
Str("commit", viper.GetString("commit")).
Msg("initialized")
global, err := cli.InitCLI()
if err != nil {
panic(err)
return err
}
return tea.RunTea(global)

34
cmd/installation/add.go Normal file
View file

@ -0,0 +1,34 @@
package installation
import (
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/spf13/cobra"
)
func init() {
Cmd.AddCommand(addCmd)
}
var addCmd = &cobra.Command{
Use: "add <path> [profile]",
Short: "Add an installation",
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
global, err := cli.InitCLI()
if err != nil {
return err
}
profile := global.Profiles.SelectedProfile
if len(args) > 1 {
profile = args[1]
}
_, err = global.Installations.AddInstallation(global, args[0], profile)
if err != nil {
return err
}
return global.Save()
},
}

28
cmd/installation/ls.go Normal file
View file

@ -0,0 +1,28 @@
package installation
import (
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/spf13/cobra"
)
func init() {
Cmd.AddCommand(lsCmd)
}
var lsCmd = &cobra.Command{
Use: "ls",
Short: "List all installations",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
global, err := cli.InitCLI()
if err != nil {
return err
}
for _, install := range global.Installations.Installations {
println(install.Path, "-", install.Profile)
}
return nil
},
}

View file

@ -0,0 +1,29 @@
package installation
import (
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/spf13/cobra"
)
func init() {
Cmd.AddCommand(removeCmd)
}
var removeCmd = &cobra.Command{
Use: "remove <path>",
Short: "Remove an installation",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
global, err := cli.InitCLI()
if err != nil {
return err
}
err = global.Installations.DeleteInstallation(args[0])
if err != nil {
return err
}
return global.Save()
},
}

10
cmd/installation/root.go Normal file
View file

@ -0,0 +1,10 @@
package installation
import (
"github.com/spf13/cobra"
)
var Cmd = &cobra.Command{
Use: "installation",
Short: "Manage installations",
}

View file

@ -0,0 +1,42 @@
package installation
import (
"github.com/pkg/errors"
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/spf13/cobra"
)
func init() {
Cmd.AddCommand(setProfileCmd)
}
var setProfileCmd = &cobra.Command{
Use: "set-profile <path> <profile>",
Short: "Change the profile of an installation",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
global, err := cli.InitCLI()
if err != nil {
return err
}
var installation *cli.Installation
for _, install := range global.Installations.Installations {
if install.Path == args[0] {
installation = install
break
}
}
if installation == nil {
return errors.New("installation not found")
}
err = installation.SetProfile(global, args[1])
if err != nil {
return err
}
return global.Save()
},
}

10
cmd/mod/root.go Normal file
View file

@ -0,0 +1,10 @@
package mod
import (
"github.com/spf13/cobra"
)
var Cmd = &cobra.Command{
Use: "mod",
Short: "Manage mods",
}

29
cmd/profile/delete.go Normal file
View file

@ -0,0 +1,29 @@
package profile
import (
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/spf13/cobra"
)
func init() {
Cmd.AddCommand(deleteCmd)
}
var deleteCmd = &cobra.Command{
Use: "delete <name>",
Short: "Delete a profile",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
global, err := cli.InitCLI()
if err != nil {
return err
}
err = global.Profiles.DeleteProfile(args[0])
if err != nil {
return err
}
return global.Save()
},
}

28
cmd/profile/ls.go Normal file
View file

@ -0,0 +1,28 @@
package profile
import (
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/spf13/cobra"
)
func init() {
Cmd.AddCommand(lsCmd)
}
var lsCmd = &cobra.Command{
Use: "ls",
Short: "List all profiles",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
global, err := cli.InitCLI()
if err != nil {
return err
}
for name := range global.Profiles.Profiles {
println(name)
}
return nil
},
}

40
cmd/profile/mod/add.go Normal file
View file

@ -0,0 +1,40 @@
package mod
import (
"fmt"
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/spf13/cobra"
)
func init() {
Cmd.AddCommand(addCmd)
}
var addCmd = &cobra.Command{
Use: "add <profile> <mod-reference> [version]",
Short: "Add mod to a profile",
Args: cobra.MinimumNArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
global, err := cli.InitCLI()
if err != nil {
return err
}
version := ">=0.0.0"
if len(args) > 2 {
version = args[2]
}
profile := global.Profiles.GetProfile(args[0])
if profile == nil {
return fmt.Errorf("profile with name %s does not exist", args[0])
}
if err := profile.AddMod(args[1], version); err != nil {
return err
}
return global.Save()
},
}

33
cmd/profile/mod/remove.go Normal file
View file

@ -0,0 +1,33 @@
package mod
import (
"fmt"
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/spf13/cobra"
)
func init() {
Cmd.AddCommand(removeCmd)
}
var removeCmd = &cobra.Command{
Use: "remove <profile> <mod-reference>",
Short: "Remove a mod from a profile",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
global, err := cli.InitCLI()
if err != nil {
return err
}
profile := global.Profiles.GetProfile(args[0])
if profile == nil {
return fmt.Errorf("profile with name %s does not exist", args[0])
}
profile.RemoveMod(args[1])
return global.Save()
},
}

10
cmd/profile/mod/root.go Normal file
View file

@ -0,0 +1,10 @@
package mod
import (
"github.com/spf13/cobra"
)
var Cmd = &cobra.Command{
Use: "mod",
Short: "Manage mods in a profile",
}

34
cmd/profile/mods.go Normal file
View file

@ -0,0 +1,34 @@
package profile
import (
"github.com/pkg/errors"
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/spf13/cobra"
)
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()
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
},
}

29
cmd/profile/new.go Normal file
View file

@ -0,0 +1,29 @@
package profile
import (
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/spf13/cobra"
)
func init() {
Cmd.AddCommand(newCmd)
}
var newCmd = &cobra.Command{
Use: "new <name>",
Short: "Create a new profile",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
global, err := cli.InitCLI()
if err != nil {
return err
}
_, err = global.Profiles.AddProfile(args[0])
if err != nil {
return err
}
return global.Save()
},
}

29
cmd/profile/rename.go Normal file
View file

@ -0,0 +1,29 @@
package profile
import (
"github.com/satisfactorymodding/ficsit-cli/cli"
"github.com/spf13/cobra"
)
func init() {
Cmd.AddCommand(renameCmd)
}
var renameCmd = &cobra.Command{
Use: "rename <old> <name>",
Short: "Rename a profile",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
global, err := cli.InitCLI()
if err != nil {
return err
}
err = global.Profiles.RenameProfile(global, args[0], args[1])
if err != nil {
return err
}
return global.Save()
},
}

10
cmd/profile/root.go Normal file
View file

@ -0,0 +1,10 @@
package profile
import (
"github.com/spf13/cobra"
)
var Cmd = &cobra.Command{
Use: "profile",
Short: "Manage profiles",
}

View file

@ -8,15 +8,17 @@ import (
"time"
"github.com/pkg/errors"
"github.com/pterm/pterm"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/satisfactorymodding/ficsit-cli/cmd/installation"
"github.com/satisfactorymodding/ficsit-cli/cmd/mod"
"github.com/satisfactorymodding/ficsit-cli/cmd/profile"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var rootCmd = &cobra.Command{
var RootCmd = &cobra.Command{
Use: "ficsit",
Short: "cli mod manager for satisfactory",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
@ -60,26 +62,21 @@ var rootCmd = &cobra.Command{
log.Logger = zerolog.New(io.MultiWriter(writers...)).With().Timestamp().Logger()
log.Info().
Str("version", viper.GetString("version")).
Str("commit", viper.GetString("commit")).
Msg("initialized")
return nil
},
}
func Execute(version string, commit string) {
// Execute tea as default
cmd, _, err := rootCmd.Find(os.Args[1:])
cmd, _, err := RootCmd.Find(os.Args[1:])
// Allow opening via explorer
cobra.MousetrapHelpText = ""
cli := len(os.Args) >= 2 && os.Args[1] == "cli"
if (len(os.Args) <= 1 || os.Args[1] != "help") && (err != nil || cmd == rootCmd) {
if (len(os.Args) <= 1 || os.Args[1] != "help") && (err != nil || cmd == RootCmd) {
args := append([]string{"cli"}, os.Args[1:]...)
rootCmd.SetArgs(args)
RootCmd.SetArgs(args)
cli = true
}
@ -91,12 +88,20 @@ func Execute(version string, commit string) {
viper.Set("version", version)
viper.Set("commit", commit)
if err := rootCmd.Execute(); err != nil {
if err := RootCmd.Execute(); err != nil {
panic(err)
}
}
func init() {
RootCmd.AddCommand(cliCmd)
RootCmd.AddCommand(applyCmd)
RootCmd.AddCommand(versionCmd)
RootCmd.AddCommand(searchCmd)
RootCmd.AddCommand(profile.Cmd)
RootCmd.AddCommand(installation.Cmd)
RootCmd.AddCommand(mod.Cmd)
var baseLocalDir string
switch runtime.GOOS {
@ -115,33 +120,33 @@ func init() {
panic(err)
}
rootCmd.PersistentFlags().String("log", "info", "The log level to output")
rootCmd.PersistentFlags().String("log-file", "", "File to output logs to")
rootCmd.PersistentFlags().Bool("quiet", false, "Do not log anything to console")
rootCmd.PersistentFlags().Bool("pretty", true, "Whether to render pretty terminal output")
RootCmd.PersistentFlags().String("log", "info", "The log level to output")
RootCmd.PersistentFlags().String("log-file", "", "File to output logs to")
RootCmd.PersistentFlags().Bool("quiet", false, "Do not log anything to console")
RootCmd.PersistentFlags().Bool("pretty", true, "Whether to render pretty terminal output")
rootCmd.PersistentFlags().Bool("dry-run", false, "Dry-run. Do not save any changes")
RootCmd.PersistentFlags().Bool("dry-run", false, "Dry-run. Do not save any changes")
rootCmd.PersistentFlags().String("cache-dir", filepath.Clean(filepath.Join(baseCacheDir, "ficsit")), "The cache directory")
rootCmd.PersistentFlags().String("local-dir", filepath.Clean(filepath.Join(baseLocalDir, "ficsit")), "The local directory")
rootCmd.PersistentFlags().String("profiles-file", "profiles.json", "The profiles file")
rootCmd.PersistentFlags().String("installations-file", "installations.json", "The installations file")
RootCmd.PersistentFlags().String("cache-dir", filepath.Clean(filepath.Join(baseCacheDir, "ficsit")), "The cache directory")
RootCmd.PersistentFlags().String("local-dir", filepath.Clean(filepath.Join(baseLocalDir, "ficsit")), "The local directory")
RootCmd.PersistentFlags().String("profiles-file", "profiles.json", "The profiles file")
RootCmd.PersistentFlags().String("installations-file", "installations.json", "The installations file")
rootCmd.PersistentFlags().String("api-base", "https://api.ficsit.app", "URL for API")
rootCmd.PersistentFlags().String("graphql-api", "/v2/query", "Path for GraphQL API")
RootCmd.PersistentFlags().String("api-base", "https://api.ficsit.app", "URL for API")
RootCmd.PersistentFlags().String("graphql-api", "/v2/query", "Path for GraphQL API")
_ = viper.BindPFlag("log", rootCmd.PersistentFlags().Lookup("log"))
_ = viper.BindPFlag("log-file", rootCmd.PersistentFlags().Lookup("log-file"))
_ = viper.BindPFlag("quiet", rootCmd.PersistentFlags().Lookup("quiet"))
_ = viper.BindPFlag("pretty", rootCmd.PersistentFlags().Lookup("pretty"))
_ = viper.BindPFlag("log", RootCmd.PersistentFlags().Lookup("log"))
_ = viper.BindPFlag("log-file", RootCmd.PersistentFlags().Lookup("log-file"))
_ = viper.BindPFlag("quiet", RootCmd.PersistentFlags().Lookup("quiet"))
_ = viper.BindPFlag("pretty", RootCmd.PersistentFlags().Lookup("pretty"))
_ = viper.BindPFlag("dry-run", rootCmd.PersistentFlags().Lookup("dry-run"))
_ = viper.BindPFlag("dry-run", RootCmd.PersistentFlags().Lookup("dry-run"))
_ = viper.BindPFlag("cache-dir", rootCmd.PersistentFlags().Lookup("cache-dir"))
_ = viper.BindPFlag("local-dir", rootCmd.PersistentFlags().Lookup("local-dir"))
_ = viper.BindPFlag("profiles-file", rootCmd.PersistentFlags().Lookup("profiles-file"))
_ = viper.BindPFlag("installations-file", rootCmd.PersistentFlags().Lookup("installations-file"))
_ = viper.BindPFlag("cache-dir", RootCmd.PersistentFlags().Lookup("cache-dir"))
_ = viper.BindPFlag("local-dir", RootCmd.PersistentFlags().Lookup("local-dir"))
_ = viper.BindPFlag("profiles-file", RootCmd.PersistentFlags().Lookup("profiles-file"))
_ = viper.BindPFlag("installations-file", RootCmd.PersistentFlags().Lookup("installations-file"))
_ = viper.BindPFlag("api-base", rootCmd.PersistentFlags().Lookup("api-base"))
_ = viper.BindPFlag("graphql-api", rootCmd.PersistentFlags().Lookup("graphql-api"))
_ = viper.BindPFlag("api-base", RootCmd.PersistentFlags().Lookup("api-base"))
_ = viper.BindPFlag("graphql-api", RootCmd.PersistentFlags().Lookup("graphql-api"))
}

68
cmd/search.go Normal file
View file

@ -0,0 +1,68 @@
package cmd
import (
"encoding/json"
"fmt"
"github.com/pkg/errors"
"github.com/satisfactorymodding/ficsit-cli/ficsit"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
func init() {
searchCmd.PersistentFlags().Int("offset", 0, "Offset of the search")
searchCmd.PersistentFlags().Int("limit", 10, "Limit of the search")
searchCmd.PersistentFlags().String("order", "desc", "Sort order of the search")
searchCmd.PersistentFlags().String("order-by", "last_version_date", "Order field of the search")
searchCmd.PersistentFlags().String("format", "list", "Order field of the search")
_ = viper.BindPFlag("offset", searchCmd.PersistentFlags().Lookup("offset"))
_ = viper.BindPFlag("limit", searchCmd.PersistentFlags().Lookup("limit"))
_ = viper.BindPFlag("order", searchCmd.PersistentFlags().Lookup("order"))
_ = viper.BindPFlag("order-by", searchCmd.PersistentFlags().Lookup("order-by"))
_ = viper.BindPFlag("format", searchCmd.PersistentFlags().Lookup("format"))
}
var searchCmd = &cobra.Command{
Use: "search [query]",
Short: "Search mods",
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client := ficsit.InitAPI()
search := ""
if len(args) > 0 {
search = args[0]
}
response, err := ficsit.Mods(cmd.Context(), client, ficsit.ModFilter{
Limit: viper.GetInt("limit"),
Offset: viper.GetInt("offset"),
Order: ficsit.Order(viper.GetString("order")),
Order_by: ficsit.ModFields(viper.GetString("order-by")),
Search: search,
})
if err != nil {
return err
}
modList := response.Mods.Mods
switch viper.GetString("format") {
default:
for _, mod := range modList {
println(fmt.Sprintf("%s (%s)", mod.Name, mod.Mod_reference))
}
case "json":
result, err := json.MarshalIndent(modList, "", " ")
if err != nil {
return errors.Wrap(err, "failed converting mods to json")
}
println(string(result))
}
return nil
},
}

14
cmd/version.go Normal file
View file

@ -0,0 +1,14 @@
package cmd
import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print current version information",
Run: func(cmd *cobra.Command, args []string) {
println(viper.GetString("version"), "-", viper.GetString("commit"))
},
}

31
docs/ficsit.md Normal file
View file

@ -0,0 +1,31 @@
## ficsit
cli mod manager for satisfactory
### Options
```
--api-base string URL for API (default "https://api.ficsit.app")
--cache-dir string The cache directory (default "/home/vilsol/.cache/ficsit")
--dry-run Dry-run. Do not save any changes
--graphql-api string Path for GraphQL API (default "/v2/query")
-h, --help help for ficsit
--installations-file string The installations file (default "installations.json")
--local-dir string The local directory (default "/home/vilsol/.local/share/ficsit")
--log string The log level to output (default "info")
--log-file string File to output logs to
--pretty Whether to render pretty terminal output (default true)
--profiles-file string The profiles file (default "profiles.json")
--quiet Do not log anything to console
```
### SEE ALSO
* [ficsit apply](ficsit_apply.md) - Apply profiles to all installations
* [ficsit cli](ficsit_cli.md) - Start interactive CLI (default)
* [ficsit installation](ficsit_installation.md) - Manage installations
* [ficsit profile](ficsit_profile.md) - Manage profiles
* [ficsit search](ficsit_search.md) - Search mods
* [ficsit version](ficsit_version.md) - Print current version information
###### Auto generated by spf13/cobra on 8-Jun-2022

35
docs/ficsit_apply.md Normal file
View file

@ -0,0 +1,35 @@
## ficsit apply
Apply profiles to all installations
```
ficsit apply [flags]
```
### Options
```
-h, --help help for apply
```
### Options inherited from parent commands
```
--api-base string URL for API (default "https://api.ficsit.app")
--cache-dir string The cache directory (default "/home/vilsol/.cache/ficsit")
--dry-run Dry-run. Do not save any changes
--graphql-api string Path for GraphQL API (default "/v2/query")
--installations-file string The installations file (default "installations.json")
--local-dir string The local directory (default "/home/vilsol/.local/share/ficsit")
--log string The log level to output (default "info")
--log-file string File to output logs to
--pretty Whether to render pretty terminal output (default true)
--profiles-file string The profiles file (default "profiles.json")
--quiet Do not log anything to console
```
### SEE ALSO
* [ficsit](ficsit.md) - cli mod manager for satisfactory
###### Auto generated by spf13/cobra on 8-Jun-2022

35
docs/ficsit_cli.md Normal file
View file

@ -0,0 +1,35 @@
## ficsit cli
Start interactive CLI (default)
```
ficsit cli [flags]
```
### Options
```
-h, --help help for cli
```
### Options inherited from parent commands
```
--api-base string URL for API (default "https://api.ficsit.app")
--cache-dir string The cache directory (default "/home/vilsol/.cache/ficsit")
--dry-run Dry-run. Do not save any changes
--graphql-api string Path for GraphQL API (default "/v2/query")
--installations-file string The installations file (default "installations.json")
--local-dir string The local directory (default "/home/vilsol/.local/share/ficsit")
--log string The log level to output (default "info")
--log-file string File to output logs to
--pretty Whether to render pretty terminal output (default true)
--profiles-file string The profiles file (default "profiles.json")
--quiet Do not log anything to console
```
### SEE ALSO
* [ficsit](ficsit.md) - cli mod manager for satisfactory
###### Auto generated by spf13/cobra on 8-Jun-2022

View file

@ -0,0 +1,35 @@
## ficsit installation
Manage installations
### Options
```
-h, --help help for installation
```
### Options inherited from parent commands
```
--api-base string URL for API (default "https://api.ficsit.app")
--cache-dir string The cache directory (default "/home/vilsol/.cache/ficsit")
--dry-run Dry-run. Do not save any changes
--graphql-api string Path for GraphQL API (default "/v2/query")
--installations-file string The installations file (default "installations.json")
--local-dir string The local directory (default "/home/vilsol/.local/share/ficsit")
--log string The log level to output (default "info")
--log-file string File to output logs to
--pretty Whether to render pretty terminal output (default true)
--profiles-file string The profiles file (default "profiles.json")
--quiet Do not log anything to console
```
### SEE ALSO
* [ficsit](ficsit.md) - cli mod manager for satisfactory
* [ficsit installation add](ficsit_installation_add.md) - Add an installation
* [ficsit installation ls](ficsit_installation_ls.md) - List all installations
* [ficsit installation remove](ficsit_installation_remove.md) - Remove an installation
* [ficsit installation set-profile](ficsit_installation_set-profile.md) - Change the profile of an installation
###### Auto generated by spf13/cobra on 8-Jun-2022

View file

@ -0,0 +1,35 @@
## ficsit installation add
Add an installation
```
ficsit installation add <path> [profile] [flags]
```
### Options
```
-h, --help help for add
```
### Options inherited from parent commands
```
--api-base string URL for API (default "https://api.ficsit.app")
--cache-dir string The cache directory (default "/home/vilsol/.cache/ficsit")
--dry-run Dry-run. Do not save any changes
--graphql-api string Path for GraphQL API (default "/v2/query")
--installations-file string The installations file (default "installations.json")
--local-dir string The local directory (default "/home/vilsol/.local/share/ficsit")
--log string The log level to output (default "info")
--log-file string File to output logs to
--pretty Whether to render pretty terminal output (default true)
--profiles-file string The profiles file (default "profiles.json")
--quiet Do not log anything to console
```
### SEE ALSO
* [ficsit installation](ficsit_installation.md) - Manage installations
###### Auto generated by spf13/cobra on 8-Jun-2022

View file

@ -0,0 +1,35 @@
## ficsit installation ls
List all installations
```
ficsit installation ls [flags]
```
### Options
```
-h, --help help for ls
```
### Options inherited from parent commands
```
--api-base string URL for API (default "https://api.ficsit.app")
--cache-dir string The cache directory (default "/home/vilsol/.cache/ficsit")
--dry-run Dry-run. Do not save any changes
--graphql-api string Path for GraphQL API (default "/v2/query")
--installations-file string The installations file (default "installations.json")
--local-dir string The local directory (default "/home/vilsol/.local/share/ficsit")
--log string The log level to output (default "info")
--log-file string File to output logs to
--pretty Whether to render pretty terminal output (default true)
--profiles-file string The profiles file (default "profiles.json")
--quiet Do not log anything to console
```
### SEE ALSO
* [ficsit installation](ficsit_installation.md) - Manage installations
###### Auto generated by spf13/cobra on 8-Jun-2022

View file

@ -0,0 +1,35 @@
## ficsit installation remove
Remove an installation
```
ficsit installation remove <path> [flags]
```
### Options
```
-h, --help help for remove
```
### Options inherited from parent commands
```
--api-base string URL for API (default "https://api.ficsit.app")
--cache-dir string The cache directory (default "/home/vilsol/.cache/ficsit")
--dry-run Dry-run. Do not save any changes
--graphql-api string Path for GraphQL API (default "/v2/query")
--installations-file string The installations file (default "installations.json")
--local-dir string The local directory (default "/home/vilsol/.local/share/ficsit")
--log string The log level to output (default "info")
--log-file string File to output logs to
--pretty Whether to render pretty terminal output (default true)
--profiles-file string The profiles file (default "profiles.json")
--quiet Do not log anything to console
```
### SEE ALSO
* [ficsit installation](ficsit_installation.md) - Manage installations
###### Auto generated by spf13/cobra on 8-Jun-2022

View file

@ -0,0 +1,35 @@
## ficsit installation set-profile
Change the profile of an installation
```
ficsit installation set-profile <path> <profile> [flags]
```
### Options
```
-h, --help help for set-profile
```
### Options inherited from parent commands
```
--api-base string URL for API (default "https://api.ficsit.app")
--cache-dir string The cache directory (default "/home/vilsol/.cache/ficsit")
--dry-run Dry-run. Do not save any changes
--graphql-api string Path for GraphQL API (default "/v2/query")
--installations-file string The installations file (default "installations.json")
--local-dir string The local directory (default "/home/vilsol/.local/share/ficsit")
--log string The log level to output (default "info")
--log-file string File to output logs to
--pretty Whether to render pretty terminal output (default true)
--profiles-file string The profiles file (default "profiles.json")
--quiet Do not log anything to console
```
### SEE ALSO
* [ficsit installation](ficsit_installation.md) - Manage installations
###### Auto generated by spf13/cobra on 8-Jun-2022

36
docs/ficsit_profile.md Normal file
View file

@ -0,0 +1,36 @@
## ficsit profile
Manage profiles
### Options
```
-h, --help help for profile
```
### Options inherited from parent commands
```
--api-base string URL for API (default "https://api.ficsit.app")
--cache-dir string The cache directory (default "/home/vilsol/.cache/ficsit")
--dry-run Dry-run. Do not save any changes
--graphql-api string Path for GraphQL API (default "/v2/query")
--installations-file string The installations file (default "installations.json")
--local-dir string The local directory (default "/home/vilsol/.local/share/ficsit")
--log string The log level to output (default "info")
--log-file string File to output logs to
--pretty Whether to render pretty terminal output (default true)
--profiles-file string The profiles file (default "profiles.json")
--quiet Do not log anything to console
```
### SEE ALSO
* [ficsit](ficsit.md) - cli mod manager for satisfactory
* [ficsit profile delete](ficsit_profile_delete.md) - Delete a profile
* [ficsit profile ls](ficsit_profile_ls.md) - List all profiles
* [ficsit profile mods](ficsit_profile_mods.md) - List all mods in a profile
* [ficsit profile new](ficsit_profile_new.md) - Create a new profile
* [ficsit profile rename](ficsit_profile_rename.md) - Rename a profile
###### Auto generated by spf13/cobra on 8-Jun-2022

View file

@ -0,0 +1,35 @@
## ficsit profile delete
Delete a profile
```
ficsit profile delete <name> [flags]
```
### Options
```
-h, --help help for delete
```
### Options inherited from parent commands
```
--api-base string URL for API (default "https://api.ficsit.app")
--cache-dir string The cache directory (default "/home/vilsol/.cache/ficsit")
--dry-run Dry-run. Do not save any changes
--graphql-api string Path for GraphQL API (default "/v2/query")
--installations-file string The installations file (default "installations.json")
--local-dir string The local directory (default "/home/vilsol/.local/share/ficsit")
--log string The log level to output (default "info")
--log-file string File to output logs to
--pretty Whether to render pretty terminal output (default true)
--profiles-file string The profiles file (default "profiles.json")
--quiet Do not log anything to console
```
### SEE ALSO
* [ficsit profile](ficsit_profile.md) - Manage profiles
###### Auto generated by spf13/cobra on 8-Jun-2022

35
docs/ficsit_profile_ls.md Normal file
View file

@ -0,0 +1,35 @@
## ficsit profile ls
List all profiles
```
ficsit profile ls [flags]
```
### Options
```
-h, --help help for ls
```
### Options inherited from parent commands
```
--api-base string URL for API (default "https://api.ficsit.app")
--cache-dir string The cache directory (default "/home/vilsol/.cache/ficsit")
--dry-run Dry-run. Do not save any changes
--graphql-api string Path for GraphQL API (default "/v2/query")
--installations-file string The installations file (default "installations.json")
--local-dir string The local directory (default "/home/vilsol/.local/share/ficsit")
--log string The log level to output (default "info")
--log-file string File to output logs to
--pretty Whether to render pretty terminal output (default true)
--profiles-file string The profiles file (default "profiles.json")
--quiet Do not log anything to console
```
### SEE ALSO
* [ficsit profile](ficsit_profile.md) - Manage profiles
###### Auto generated by spf13/cobra on 8-Jun-2022

View file

@ -0,0 +1,35 @@
## ficsit profile mods
List all mods in a profile
```
ficsit profile mods <profile> [flags]
```
### Options
```
-h, --help help for mods
```
### Options inherited from parent commands
```
--api-base string URL for API (default "https://api.ficsit.app")
--cache-dir string The cache directory (default "/home/vilsol/.cache/ficsit")
--dry-run Dry-run. Do not save any changes
--graphql-api string Path for GraphQL API (default "/v2/query")
--installations-file string The installations file (default "installations.json")
--local-dir string The local directory (default "/home/vilsol/.local/share/ficsit")
--log string The log level to output (default "info")
--log-file string File to output logs to
--pretty Whether to render pretty terminal output (default true)
--profiles-file string The profiles file (default "profiles.json")
--quiet Do not log anything to console
```
### SEE ALSO
* [ficsit profile](ficsit_profile.md) - Manage profiles
###### Auto generated by spf13/cobra on 8-Jun-2022

View file

@ -0,0 +1,35 @@
## ficsit profile new
Create a new profile
```
ficsit profile new <name> [flags]
```
### Options
```
-h, --help help for new
```
### Options inherited from parent commands
```
--api-base string URL for API (default "https://api.ficsit.app")
--cache-dir string The cache directory (default "/home/vilsol/.cache/ficsit")
--dry-run Dry-run. Do not save any changes
--graphql-api string Path for GraphQL API (default "/v2/query")
--installations-file string The installations file (default "installations.json")
--local-dir string The local directory (default "/home/vilsol/.local/share/ficsit")
--log string The log level to output (default "info")
--log-file string File to output logs to
--pretty Whether to render pretty terminal output (default true)
--profiles-file string The profiles file (default "profiles.json")
--quiet Do not log anything to console
```
### SEE ALSO
* [ficsit profile](ficsit_profile.md) - Manage profiles
###### Auto generated by spf13/cobra on 8-Jun-2022

View file

@ -0,0 +1,35 @@
## ficsit profile rename
Rename a profile
```
ficsit profile rename <old> <name> [flags]
```
### Options
```
-h, --help help for rename
```
### Options inherited from parent commands
```
--api-base string URL for API (default "https://api.ficsit.app")
--cache-dir string The cache directory (default "/home/vilsol/.cache/ficsit")
--dry-run Dry-run. Do not save any changes
--graphql-api string Path for GraphQL API (default "/v2/query")
--installations-file string The installations file (default "installations.json")
--local-dir string The local directory (default "/home/vilsol/.local/share/ficsit")
--log string The log level to output (default "info")
--log-file string File to output logs to
--pretty Whether to render pretty terminal output (default true)
--profiles-file string The profiles file (default "profiles.json")
--quiet Do not log anything to console
```
### SEE ALSO
* [ficsit profile](ficsit_profile.md) - Manage profiles
###### Auto generated by spf13/cobra on 8-Jun-2022

40
docs/ficsit_search.md Normal file
View file

@ -0,0 +1,40 @@
## ficsit search
Search mods
```
ficsit search [query] [flags]
```
### Options
```
--format string Order field of the search (default "list")
-h, --help help for search
--limit int Limit of the search (default 10)
--offset int Offset of the search
--order string Sort order of the search (default "desc")
--order-by string Order field of the search (default "last_version_date")
```
### Options inherited from parent commands
```
--api-base string URL for API (default "https://api.ficsit.app")
--cache-dir string The cache directory (default "/home/vilsol/.cache/ficsit")
--dry-run Dry-run. Do not save any changes
--graphql-api string Path for GraphQL API (default "/v2/query")
--installations-file string The installations file (default "installations.json")
--local-dir string The local directory (default "/home/vilsol/.local/share/ficsit")
--log string The log level to output (default "info")
--log-file string File to output logs to
--pretty Whether to render pretty terminal output (default true)
--profiles-file string The profiles file (default "profiles.json")
--quiet Do not log anything to console
```
### SEE ALSO
* [ficsit](ficsit.md) - cli mod manager for satisfactory
###### Auto generated by spf13/cobra on 8-Jun-2022

35
docs/ficsit_version.md Normal file
View file

@ -0,0 +1,35 @@
## ficsit version
Print current version information
```
ficsit version [flags]
```
### Options
```
-h, --help help for version
```
### Options inherited from parent commands
```
--api-base string URL for API (default "https://api.ficsit.app")
--cache-dir string The cache directory (default "/home/vilsol/.cache/ficsit")
--dry-run Dry-run. Do not save any changes
--graphql-api string Path for GraphQL API (default "/v2/query")
--installations-file string The installations file (default "installations.json")
--local-dir string The local directory (default "/home/vilsol/.local/share/ficsit")
--log string The log level to output (default "info")
--log-file string File to output logs to
--pretty Whether to render pretty terminal output (default true)
--profiles-file string The profiles file (default "profiles.json")
--quiet Do not log anything to console
```
### SEE ALSO
* [ficsit](ficsit.md) - cli mod manager for satisfactory
###### Auto generated by spf13/cobra on 8-Jun-2022

4
go.mod
View file

@ -34,6 +34,7 @@ require (
github.com/aymerick/douceur v0.2.0 // indirect
github.com/charmbracelet/harmonica v0.2.0 // indirect
github.com/containerd/console v1.0.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dlclark/regexp2 v1.4.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
@ -55,6 +56,7 @@ require (
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
@ -65,7 +67,7 @@ require (
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
github.com/yuin/goldmark v1.4.4 // indirect
github.com/yuin/goldmark-emoji v1.0.1 // indirect
golang.org/x/mod v0.5.0 // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect

5
go.sum
View file

@ -103,6 +103,7 @@ github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARu
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@ -279,6 +280,7 @@ github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.26.1 h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc=
github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sahilm/fuzzy v0.1.0 h1:FzWGaw2Opqyu+794ZQ9SYifWv2EIXpwP4q8dY1kDAwI=
github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
@ -380,9 +382,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.5.0 h1:UG21uOlmZabA4fW5i7ZX6bjw1xELEGg/ZLgZq9auk/Q=
golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=

View file

@ -52,7 +52,7 @@ func (m renameProfile) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case KeyEscape:
return m.parent, nil
case KeyEnter:
if err := m.root.GetGlobal().Profiles.RenameProfile(m.oldName, m.input.Value()); err != nil {
if err := m.root.GetGlobal().Profiles.RenameProfile(m.root.GetGlobal(), m.oldName, m.input.Value()); err != nil {
errorComponent, cmd := components.NewErrorComponent(err.Error(), time.Second*5)
m.error = errorComponent
return m, cmd

View file

@ -1,8 +1,27 @@
//go:build tools
// +build tools
package smr
package main
import _ "github.com/Khan/genqlient"
import (
_ "github.com/Khan/genqlient/generate"
"github.com/satisfactorymodding/ficsit-cli/cmd"
"github.com/spf13/cobra/doc"
"os"
)
//go:generate go run -tags tools tools.go
//go:generate go run github.com/Khan/genqlient
func main() {
_ = os.RemoveAll("./docs/")
if err := os.Mkdir("./docs/", 0777); err != nil {
panic(err)
}
err := doc.GenMarkdownTree(cmd.RootCmd, "./docs/")
if err != nil {
panic(err)
}
}