78 lines
3.0 KiB
Go
78 lines
3.0 KiB
Go
/*
|
|
Copyright © 2025 s1d3sw1ped
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
all copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
THE SOFTWARE.
|
|
*/
|
|
package cmd
|
|
|
|
import (
|
|
"os"
|
|
"s1d3sw1ped/SteamCache2/steamcache"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
address string
|
|
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(
|
|
address,
|
|
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(&address, "address", "a", ":80", "The address to listen on")
|
|
rootCmd.Flags().StringVarP(&memory, "memory", "m", "100MB", "The size of the memory cache")
|
|
rootCmd.Flags().IntVarP(&memorymultiplier, "memory-multiplier", "M", 10, "The multiplier for the memory cache")
|
|
rootCmd.Flags().StringVarP(&disk, "disk", "d", "10GB", "The size of the disk cache")
|
|
rootCmd.Flags().IntVarP(&diskmultiplier, "disk-multiplier", "D", 10, "The multiplier for the disk cache")
|
|
rootCmd.Flags().StringVarP(&diskpath, "disk-path", "p", "tmp/steamcache2-disk", "The path to the disk cache")
|
|
}
|