From e01db90b0bda0e2562cd0aae6c9221c5274321bf Mon Sep 17 00:00:00 2001 From: Vilsol Date: Wed, 8 Jun 2022 23:56:32 +0300 Subject: [PATCH] add cli commands, docs, readme --- .goreleaser.yml | 21 +++++++- README.md | 59 ++++++++++++++++++++ cli/profiles.go | 8 ++- cmd/apply.go | 14 +++++ cmd/cli.go | 15 +++--- cmd/installation/add.go | 34 ++++++++++++ cmd/installation/ls.go | 28 ++++++++++ cmd/installation/remove.go | 29 ++++++++++ cmd/installation/root.go | 10 ++++ cmd/installation/set-profile.go | 42 +++++++++++++++ cmd/mod/root.go | 10 ++++ cmd/profile/delete.go | 29 ++++++++++ cmd/profile/ls.go | 28 ++++++++++ cmd/profile/mod/add.go | 40 ++++++++++++++ cmd/profile/mod/remove.go | 33 ++++++++++++ cmd/profile/mod/root.go | 10 ++++ cmd/profile/mods.go | 34 ++++++++++++ cmd/profile/new.go | 29 ++++++++++ cmd/profile/rename.go | 29 ++++++++++ cmd/profile/root.go | 10 ++++ cmd/root.go | 71 +++++++++++++------------ cmd/search.go | 68 +++++++++++++++++++++++ cmd/version.go | 14 +++++ docs/ficsit.md | 31 +++++++++++ docs/ficsit_apply.md | 35 ++++++++++++ docs/ficsit_cli.md | 35 ++++++++++++ docs/ficsit_installation.md | 35 ++++++++++++ docs/ficsit_installation_add.md | 35 ++++++++++++ docs/ficsit_installation_ls.md | 35 ++++++++++++ docs/ficsit_installation_remove.md | 35 ++++++++++++ docs/ficsit_installation_set-profile.md | 35 ++++++++++++ docs/ficsit_profile.md | 36 +++++++++++++ docs/ficsit_profile_delete.md | 35 ++++++++++++ docs/ficsit_profile_ls.md | 35 ++++++++++++ docs/ficsit_profile_mods.md | 35 ++++++++++++ docs/ficsit_profile_new.md | 35 ++++++++++++ docs/ficsit_profile_rename.md | 35 ++++++++++++ docs/ficsit_search.md | 40 ++++++++++++++ docs/ficsit_version.md | 35 ++++++++++++ go.mod | 4 +- go.sum | 5 +- tea/scenes/rename_profile.go | 2 +- tools.go | 23 +++++++- 43 files changed, 1213 insertions(+), 48 deletions(-) create mode 100644 README.md create mode 100644 cmd/apply.go create mode 100644 cmd/installation/add.go create mode 100644 cmd/installation/ls.go create mode 100644 cmd/installation/remove.go create mode 100644 cmd/installation/root.go create mode 100644 cmd/installation/set-profile.go create mode 100644 cmd/mod/root.go create mode 100644 cmd/profile/delete.go create mode 100644 cmd/profile/ls.go create mode 100644 cmd/profile/mod/add.go create mode 100644 cmd/profile/mod/remove.go create mode 100644 cmd/profile/mod/root.go create mode 100644 cmd/profile/mods.go create mode 100644 cmd/profile/new.go create mode 100644 cmd/profile/rename.go create mode 100644 cmd/profile/root.go create mode 100644 cmd/search.go create mode 100644 cmd/version.go create mode 100644 docs/ficsit.md create mode 100644 docs/ficsit_apply.md create mode 100644 docs/ficsit_cli.md create mode 100644 docs/ficsit_installation.md create mode 100644 docs/ficsit_installation_add.md create mode 100644 docs/ficsit_installation_ls.md create mode 100644 docs/ficsit_installation_remove.md create mode 100644 docs/ficsit_installation_set-profile.md create mode 100644 docs/ficsit_profile.md create mode 100644 docs/ficsit_profile_delete.md create mode 100644 docs/ficsit_profile_ls.md create mode 100644 docs/ficsit_profile_mods.md create mode 100644 docs/ficsit_profile_new.md create mode 100644 docs/ficsit_profile_rename.md create mode 100644 docs/ficsit_search.md create mode 100644 docs/ficsit_version.md diff --git a/.goreleaser.yml b/.goreleaser.yml index ea6eb61..e1ef24c 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -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 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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..c76cf47 --- /dev/null +++ b/README.md @@ -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). \ No newline at end of file diff --git a/cli/profiles.go b/cli/profiles.go index 8285cee..0908c46 100644 --- a/cli/profiles.go +++ b/cli/profiles.go @@ -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 } diff --git a/cmd/apply.go b/cmd/apply.go new file mode 100644 index 0000000..f1c14b6 --- /dev/null +++ b/cmd/apply.go @@ -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 + }, +} diff --git a/cmd/cli.go b/cmd/cli.go index 7e63fbd..77cdde8 100644 --- a/cmd/cli.go +++ b/cmd/cli.go @@ -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) diff --git a/cmd/installation/add.go b/cmd/installation/add.go new file mode 100644 index 0000000..1c182f2 --- /dev/null +++ b/cmd/installation/add.go @@ -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 [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() + }, +} diff --git a/cmd/installation/ls.go b/cmd/installation/ls.go new file mode 100644 index 0000000..9455ff0 --- /dev/null +++ b/cmd/installation/ls.go @@ -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 + }, +} diff --git a/cmd/installation/remove.go b/cmd/installation/remove.go new file mode 100644 index 0000000..154c84c --- /dev/null +++ b/cmd/installation/remove.go @@ -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 ", + 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() + }, +} diff --git a/cmd/installation/root.go b/cmd/installation/root.go new file mode 100644 index 0000000..44427d6 --- /dev/null +++ b/cmd/installation/root.go @@ -0,0 +1,10 @@ +package installation + +import ( + "github.com/spf13/cobra" +) + +var Cmd = &cobra.Command{ + Use: "installation", + Short: "Manage installations", +} diff --git a/cmd/installation/set-profile.go b/cmd/installation/set-profile.go new file mode 100644 index 0000000..678ccca --- /dev/null +++ b/cmd/installation/set-profile.go @@ -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 ", + 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() + }, +} diff --git a/cmd/mod/root.go b/cmd/mod/root.go new file mode 100644 index 0000000..9d898ee --- /dev/null +++ b/cmd/mod/root.go @@ -0,0 +1,10 @@ +package mod + +import ( + "github.com/spf13/cobra" +) + +var Cmd = &cobra.Command{ + Use: "mod", + Short: "Manage mods", +} diff --git a/cmd/profile/delete.go b/cmd/profile/delete.go new file mode 100644 index 0000000..84c449b --- /dev/null +++ b/cmd/profile/delete.go @@ -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 ", + 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() + }, +} diff --git a/cmd/profile/ls.go b/cmd/profile/ls.go new file mode 100644 index 0000000..3958269 --- /dev/null +++ b/cmd/profile/ls.go @@ -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 + }, +} diff --git a/cmd/profile/mod/add.go b/cmd/profile/mod/add.go new file mode 100644 index 0000000..31ef346 --- /dev/null +++ b/cmd/profile/mod/add.go @@ -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 [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() + }, +} diff --git a/cmd/profile/mod/remove.go b/cmd/profile/mod/remove.go new file mode 100644 index 0000000..f6181f3 --- /dev/null +++ b/cmd/profile/mod/remove.go @@ -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 ", + 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() + }, +} diff --git a/cmd/profile/mod/root.go b/cmd/profile/mod/root.go new file mode 100644 index 0000000..21c7dc0 --- /dev/null +++ b/cmd/profile/mod/root.go @@ -0,0 +1,10 @@ +package mod + +import ( + "github.com/spf13/cobra" +) + +var Cmd = &cobra.Command{ + Use: "mod", + Short: "Manage mods in a profile", +} diff --git a/cmd/profile/mods.go b/cmd/profile/mods.go new file mode 100644 index 0000000..51d79c9 --- /dev/null +++ b/cmd/profile/mods.go @@ -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 ", + 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 + }, +} diff --git a/cmd/profile/new.go b/cmd/profile/new.go new file mode 100644 index 0000000..a9733be --- /dev/null +++ b/cmd/profile/new.go @@ -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 ", + 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() + }, +} diff --git a/cmd/profile/rename.go b/cmd/profile/rename.go new file mode 100644 index 0000000..b75e0cf --- /dev/null +++ b/cmd/profile/rename.go @@ -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 ", + 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() + }, +} diff --git a/cmd/profile/root.go b/cmd/profile/root.go new file mode 100644 index 0000000..dd7cacd --- /dev/null +++ b/cmd/profile/root.go @@ -0,0 +1,10 @@ +package profile + +import ( + "github.com/spf13/cobra" +) + +var Cmd = &cobra.Command{ + Use: "profile", + Short: "Manage profiles", +} diff --git a/cmd/root.go b/cmd/root.go index 468eb46..ddbd247 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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")) } diff --git a/cmd/search.go b/cmd/search.go new file mode 100644 index 0000000..d1ffba7 --- /dev/null +++ b/cmd/search.go @@ -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 + }, +} diff --git a/cmd/version.go b/cmd/version.go new file mode 100644 index 0000000..f5a1170 --- /dev/null +++ b/cmd/version.go @@ -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")) + }, +} diff --git a/docs/ficsit.md b/docs/ficsit.md new file mode 100644 index 0000000..8a4242d --- /dev/null +++ b/docs/ficsit.md @@ -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 diff --git a/docs/ficsit_apply.md b/docs/ficsit_apply.md new file mode 100644 index 0000000..a3b23d5 --- /dev/null +++ b/docs/ficsit_apply.md @@ -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 diff --git a/docs/ficsit_cli.md b/docs/ficsit_cli.md new file mode 100644 index 0000000..fc81ced --- /dev/null +++ b/docs/ficsit_cli.md @@ -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 diff --git a/docs/ficsit_installation.md b/docs/ficsit_installation.md new file mode 100644 index 0000000..5a968bc --- /dev/null +++ b/docs/ficsit_installation.md @@ -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 diff --git a/docs/ficsit_installation_add.md b/docs/ficsit_installation_add.md new file mode 100644 index 0000000..dd4a756 --- /dev/null +++ b/docs/ficsit_installation_add.md @@ -0,0 +1,35 @@ +## ficsit installation add + +Add an installation + +``` +ficsit installation add [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 diff --git a/docs/ficsit_installation_ls.md b/docs/ficsit_installation_ls.md new file mode 100644 index 0000000..642f2a6 --- /dev/null +++ b/docs/ficsit_installation_ls.md @@ -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 diff --git a/docs/ficsit_installation_remove.md b/docs/ficsit_installation_remove.md new file mode 100644 index 0000000..f35cbf7 --- /dev/null +++ b/docs/ficsit_installation_remove.md @@ -0,0 +1,35 @@ +## ficsit installation remove + +Remove an installation + +``` +ficsit installation remove [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 diff --git a/docs/ficsit_installation_set-profile.md b/docs/ficsit_installation_set-profile.md new file mode 100644 index 0000000..0be226d --- /dev/null +++ b/docs/ficsit_installation_set-profile.md @@ -0,0 +1,35 @@ +## ficsit installation set-profile + +Change the profile of an installation + +``` +ficsit installation set-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 diff --git a/docs/ficsit_profile.md b/docs/ficsit_profile.md new file mode 100644 index 0000000..fa7100e --- /dev/null +++ b/docs/ficsit_profile.md @@ -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 diff --git a/docs/ficsit_profile_delete.md b/docs/ficsit_profile_delete.md new file mode 100644 index 0000000..460395e --- /dev/null +++ b/docs/ficsit_profile_delete.md @@ -0,0 +1,35 @@ +## ficsit profile delete + +Delete a profile + +``` +ficsit profile delete [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 diff --git a/docs/ficsit_profile_ls.md b/docs/ficsit_profile_ls.md new file mode 100644 index 0000000..427e79a --- /dev/null +++ b/docs/ficsit_profile_ls.md @@ -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 diff --git a/docs/ficsit_profile_mods.md b/docs/ficsit_profile_mods.md new file mode 100644 index 0000000..2eda5a9 --- /dev/null +++ b/docs/ficsit_profile_mods.md @@ -0,0 +1,35 @@ +## ficsit profile mods + +List all mods in a profile + +``` +ficsit profile mods [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 diff --git a/docs/ficsit_profile_new.md b/docs/ficsit_profile_new.md new file mode 100644 index 0000000..4bb4598 --- /dev/null +++ b/docs/ficsit_profile_new.md @@ -0,0 +1,35 @@ +## ficsit profile new + +Create a new profile + +``` +ficsit profile new [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 diff --git a/docs/ficsit_profile_rename.md b/docs/ficsit_profile_rename.md new file mode 100644 index 0000000..fb75ec1 --- /dev/null +++ b/docs/ficsit_profile_rename.md @@ -0,0 +1,35 @@ +## ficsit profile rename + +Rename a profile + +``` +ficsit profile rename [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 diff --git a/docs/ficsit_search.md b/docs/ficsit_search.md new file mode 100644 index 0000000..8a569b4 --- /dev/null +++ b/docs/ficsit_search.md @@ -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 diff --git a/docs/ficsit_version.md b/docs/ficsit_version.md new file mode 100644 index 0000000..3866c24 --- /dev/null +++ b/docs/ficsit_version.md @@ -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 diff --git a/go.mod b/go.mod index 49f33e1..51997e8 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 707b3c5..c816bba 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/tea/scenes/rename_profile.go b/tea/scenes/rename_profile.go index b370dce..b33533c 100644 --- a/tea/scenes/rename_profile.go +++ b/tea/scenes/rename_profile.go @@ -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 diff --git a/tools.go b/tools.go index ef095b2..9a26651 100644 --- a/tools.go +++ b/tools.go @@ -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) + } +}