add gamelist location as a parameter
This commit is contained in:
@@ -26,23 +26,28 @@ type CfgCmd struct {
|
||||
}
|
||||
|
||||
type args struct {
|
||||
Scan *ScanCmd `arg:"subcommand:scan"`
|
||||
Rename *RenameCmd `arg:"subcommand:rename"`
|
||||
Art *ArtCmd `arg:"subcommand:art"`
|
||||
Cfg *CfgCmd `arg:"subcommand:cfg"`
|
||||
Scan *ScanCmd `arg:"subcommand:scan"`
|
||||
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")
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user