implmented rename subcommand
This commit is contained in:
@@ -9,8 +9,13 @@ type ScanCmd struct {
|
|||||||
File string `arg:"positional"`
|
File string `arg:"positional"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RenameCmd struct {
|
||||||
|
File string `arg:"positional"`
|
||||||
|
}
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
Scan *ScanCmd `arg:"subcommand:scan"`
|
Scan *ScanCmd `arg:"subcommand:scan"`
|
||||||
|
Rename *RenameCmd `arg:"subcommand:rename"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func Run() {
|
func Run() {
|
||||||
@@ -20,5 +25,7 @@ func Run() {
|
|||||||
switch {
|
switch {
|
||||||
case args.Scan != nil:
|
case args.Scan != nil:
|
||||||
oplcli.Scan(args.Scan.File, oplcli.Config{})
|
oplcli.Scan(args.Scan.File, oplcli.Config{})
|
||||||
|
case args.Rename != nil:
|
||||||
|
oplcli.Rename(args.Rename.File, oplcli.Config{})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,38 @@ func Scan(file string, config Config) {
|
|||||||
gameList, err := loadGamelist("./ps2-gameslist.txt")
|
gameList, err := loadGamelist("./ps2-gameslist.txt")
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
gameName := gameList[gameID]
|
gameName := gameList[gameID]
|
||||||
fmt.Printf("Found game name: %s\n", gameName)
|
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)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user