allow multiple files to be processed
This commit is contained in:
@@ -6,15 +6,15 @@ import (
|
||||
)
|
||||
|
||||
type ScanCmd struct {
|
||||
File string `arg:"positional"`
|
||||
Files []string `arg:"positional"`
|
||||
}
|
||||
|
||||
type RenameCmd struct {
|
||||
File string `arg:"positional"`
|
||||
Files []string `arg:"positional"`
|
||||
}
|
||||
|
||||
type ArtCmd struct {
|
||||
File string `arg:"positional"`
|
||||
Files []string `arg:"positional"`
|
||||
}
|
||||
|
||||
type args struct {
|
||||
@@ -25,14 +25,23 @@ type args struct {
|
||||
|
||||
func Run() {
|
||||
var args args
|
||||
arg.MustParse(&args)
|
||||
p := arg.MustParse(&args)
|
||||
|
||||
switch {
|
||||
case args.Scan != nil:
|
||||
oplcli.Scan(args.Scan.File, oplcli.Config{})
|
||||
if len(args.Scan.Files) == 0 {
|
||||
p.Fail("Provide at least one file to scan")
|
||||
}
|
||||
oplcli.Scan(args.Scan.Files, oplcli.Config{})
|
||||
case args.Rename != nil:
|
||||
oplcli.Rename(args.Rename.File, oplcli.Config{})
|
||||
if len(args.Rename.Files) == 0 {
|
||||
p.Fail("Provide at least one file rename")
|
||||
}
|
||||
oplcli.Rename(args.Rename.Files, oplcli.Config{})
|
||||
case args.Art != nil:
|
||||
oplcli.DownloadGameArt(args.Art.File, oplcli.Config{})
|
||||
if len(args.Art.Files) == 0 {
|
||||
p.Fail("Provide at least one file to download art for")
|
||||
}
|
||||
oplcli.DownloadGameArt(args.Art.Files, oplcli.Config{})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,66 +8,71 @@ import (
|
||||
type Config struct {
|
||||
}
|
||||
|
||||
func Scan(file string, config Config) {
|
||||
fmt.Printf("Scanning file: %s\n", file)
|
||||
|
||||
gameID, err := scanGameFileForID(file)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to scan game file: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("Found game ID: %s\n", gameID)
|
||||
|
||||
func Scan(files []string, config Config) {
|
||||
gameList, err := loadGamelist("./ps2-gameslist.txt")
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to load game list: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
gameName := gameList[gameID]
|
||||
fmt.Printf("Found game name: %s\n", gameName)
|
||||
for _, file := range files {
|
||||
fmt.Printf("Scanning file: %s\n", file)
|
||||
gameID, err := scanGameFileForID(file)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to scan game file: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("Found game ID: %s\n", gameID)
|
||||
|
||||
gameName := gameList[gameID]
|
||||
fmt.Printf("Found game name: %s\n", gameName)
|
||||
}
|
||||
}
|
||||
|
||||
func Rename(file string, config Config) {
|
||||
fmt.Printf("Scanning file: %s\n", file)
|
||||
|
||||
gameID, err := scanGameFileForID(file)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to scan game file: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("Found game ID: %s\n", gameID)
|
||||
|
||||
func Rename(files []string, config Config) {
|
||||
gameList, err := loadGamelist("./ps2-gameslist.txt")
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to load game list: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
gameName := gameList[gameID]
|
||||
fmt.Printf("Found game name: %s\n", gameName)
|
||||
for _, file := range files {
|
||||
fmt.Printf("Scanning file: %s\n", file)
|
||||
|
||||
newPath, err := renameGameFile(file, gameName)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to rename file: %v", err)
|
||||
os.Exit(1)
|
||||
gameID, err := scanGameFileForID(file)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to scan game file: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("Found game ID: %s\n", gameID)
|
||||
|
||||
gameName := gameList[gameID]
|
||||
fmt.Printf("Found game name: %s\n", gameName)
|
||||
|
||||
newPath, err := renameGameFile(file, gameName)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to rename file: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("Renamed %s to %s", file, newPath)
|
||||
}
|
||||
|
||||
fmt.Printf("Renamed %s to %s", file, newPath)
|
||||
}
|
||||
|
||||
func DownloadGameArt(file string, config Config) {
|
||||
fmt.Printf("Scanning file: %s\n", file)
|
||||
func DownloadGameArt(files []string, config Config) {
|
||||
for _, file := range files {
|
||||
fmt.Printf("Scanning file: %s\n", file)
|
||||
|
||||
gameID, err := scanGameFileForID(file)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to scan game file: %s", err)
|
||||
os.Exit(1)
|
||||
gameID, err := scanGameFileForID(file)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to scan game file: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("Found game ID: %s\n", gameID)
|
||||
|
||||
downloadArtForGame(gameID, "./ignore")
|
||||
}
|
||||
|
||||
fmt.Printf("Found game ID: %s\n", gameID)
|
||||
|
||||
downloadArtForGame(gameID, "./art")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user