add gamelist location as a parameter
This commit is contained in:
@@ -26,23 +26,28 @@ type CfgCmd struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
Scan *ScanCmd `arg:"subcommand:scan"`
|
Scan *ScanCmd `arg:"subcommand:scan"`
|
||||||
Rename *RenameCmd `arg:"subcommand:rename"`
|
Rename *RenameCmd `arg:"subcommand:rename"`
|
||||||
Art *ArtCmd `arg:"subcommand:art"`
|
Art *ArtCmd `arg:"subcommand:art"`
|
||||||
Cfg *CfgCmd `arg:"subcommand:cfg"`
|
Cfg *CfgCmd `arg:"subcommand:cfg"`
|
||||||
|
GameListLocation string `args:"--gamelist" default:"./ps2-gameslist.txt" help:"Location of game list"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func Run() {
|
func Run() {
|
||||||
var args args
|
var args args
|
||||||
p := arg.MustParse(&args)
|
p := arg.MustParse(&args)
|
||||||
|
|
||||||
|
config := oplcli.Config{
|
||||||
|
GameListLocation: args.GameListLocation,
|
||||||
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case args.Scan != nil:
|
case args.Scan != nil:
|
||||||
oplcli.Scan(args.Scan.Files, oplcli.Config{})
|
oplcli.Scan(args.Scan.Files, config)
|
||||||
case args.Rename != nil:
|
case args.Rename != nil:
|
||||||
oplcli.Rename(args.Rename.Files, oplcli.Config{})
|
oplcli.Rename(args.Rename.Files, config)
|
||||||
case args.Art != nil:
|
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:
|
case args.Cfg != nil:
|
||||||
if args.Cfg.Override && args.Cfg.Append {
|
if args.Cfg.Override && args.Cfg.Append {
|
||||||
p.FailSubcommand("Can only append or override cfg files", "cfg")
|
p.FailSubcommand("Can only append or override cfg files", "cfg")
|
||||||
@@ -58,7 +63,7 @@ func Run() {
|
|||||||
mode = oplcli.ModeOverride
|
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:
|
default:
|
||||||
p.Fail("Must specify command")
|
p.Fail("Must specify command")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
GameListLocation string
|
||||||
}
|
}
|
||||||
|
|
||||||
func Scan(files []string, config Config) {
|
func Scan(files []string, config Config) {
|
||||||
gameList, err := loadGamelist("./ps2-gameslist.txt")
|
gameList, err := loadGamelist(config.GameListLocation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to load game list: %v", err)
|
fmt.Printf("Failed to load game list: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -31,7 +32,7 @@ func Scan(files []string, config Config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Rename(files []string, config Config) {
|
func Rename(files []string, config Config) {
|
||||||
gameList, err := loadGamelist("./ps2-gameslist.txt")
|
gameList, err := loadGamelist(config.GameListLocation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to load game list: %v", err)
|
fmt.Printf("Failed to load game list: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user