add gamelist location as a parameter

This commit is contained in:
2026-01-07 20:35:48 +01:00
parent 79d9d300cb
commit 42a1080981
2 changed files with 16 additions and 10 deletions

View File

@@ -30,19 +30,24 @@ type args struct {
Rename *RenameCmd `arg:"subcommand:rename"`
Art *ArtCmd `arg:"subcommand:art"`
Cfg *CfgCmd `arg:"subcommand:cfg"`
GameListLocation string `args:"--gamelist" default:"./ps2-gameslist.txt" help:"Location of game list"`
}
func Run() {
var args args
p := arg.MustParse(&args)
config := oplcli.Config{
GameListLocation: args.GameListLocation,
}
switch {
case args.Scan != nil:
oplcli.Scan(args.Scan.Files, oplcli.Config{})
oplcli.Scan(args.Scan.Files, config)
case args.Rename != nil:
oplcli.Rename(args.Rename.Files, oplcli.Config{})
oplcli.Rename(args.Rename.Files, config)
case args.Art != nil:
oplcli.DownloadGameArt(args.Art.Files, args.Art.OutputDirectory, oplcli.Config{})
oplcli.DownloadGameArt(args.Art.Files, args.Art.OutputDirectory, config)
case args.Cfg != nil:
if args.Cfg.Override && args.Cfg.Append {
p.FailSubcommand("Can only append or override cfg files", "cfg")
@@ -58,7 +63,7 @@ func Run() {
mode = oplcli.ModeOverride
}
oplcli.DownloadCfg(args.Cfg.Files, args.Cfg.OutputDirectory, mode, oplcli.Config{})
oplcli.DownloadCfg(args.Cfg.Files, args.Cfg.OutputDirectory, mode, config)
default:
p.Fail("Must specify command")
}

View File

@@ -6,10 +6,11 @@ import (
)
type Config struct {
GameListLocation string
}
func Scan(files []string, config Config) {
gameList, err := loadGamelist("./ps2-gameslist.txt")
gameList, err := loadGamelist(config.GameListLocation)
if err != nil {
fmt.Printf("Failed to load game list: %v", err)
os.Exit(1)
@@ -31,7 +32,7 @@ func Scan(files []string, config Config) {
}
func Rename(files []string, config Config) {
gameList, err := loadGamelist("./ps2-gameslist.txt")
gameList, err := loadGamelist(config.GameListLocation)
if err != nil {
fmt.Printf("Failed to load game list: %v", err)
os.Exit(1)