Files
steamcache2/cmd/root.go
Justin Harms 7401c040dc
All checks were successful
Release Tag / release (push) Successful in 14s
feat: add configurations for memory only, disk only, and memory & disk modes
2025-01-22 19:28:45 -06:00

55 lines
1.8 KiB
Go

package cmd
import (
"os"
"s1d3sw1ped/SteamCache2/steamcache"
"github.com/spf13/cobra"
)
var (
memory string
memorymultiplier int
disk string
diskmultiplier int
diskpath string
)
var rootCmd = &cobra.Command{
Use: "SteamCache2",
Short: "SteamCache2 is a caching solution for Steam game updates and installations",
Long: `SteamCache2 is a caching solution designed to optimize the delivery of Steam game updates and installations.
It reduces bandwidth usage and speeds up the download process by caching game files locally.
This tool is particularly useful for environments with multiple Steam users, such as gaming cafes or households with multiple gamers.
By caching game files, SteamCache2 ensures that subsequent downloads of the same files are served from the local cache,
significantly improving download times and reducing the load on the internet connection.`,
Run: func(cmd *cobra.Command, args []string) {
sc := steamcache.New(
":80",
memory,
memorymultiplier,
disk,
diskmultiplier,
diskpath,
)
sc.Run()
},
}
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}
func init() {
rootCmd.Flags().StringVarP(&memory, "memory", "m", "0", "The size of the memory cache")
rootCmd.Flags().IntVarP(&memorymultiplier, "memory-gc", "M", 10, "The gc value for the memory cache")
rootCmd.Flags().StringVarP(&disk, "disk", "d", "0", "The size of the disk cache")
rootCmd.Flags().IntVarP(&diskmultiplier, "disk-gc", "D", 100, "The gc value for the disk cache")
rootCmd.Flags().StringVarP(&diskpath, "disk-path", "p", "", "The path to the disk cache")
}