From 8d308178ebcf8819ad42b4cecf66933ee86cf034 Mon Sep 17 00:00:00 2001 From: Niklas Kapelle Date: Tue, 6 Jan 2026 20:31:25 +0100 Subject: [PATCH] cli args improvements --- cmd/oplcli.go | 20 ++++++-------------- internal/oplcli.go | 4 ++-- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/cmd/oplcli.go b/cmd/oplcli.go index 92ad8aa..3e74fcb 100644 --- a/cmd/oplcli.go +++ b/cmd/oplcli.go @@ -6,15 +6,16 @@ import ( ) type ScanCmd struct { - Files []string `arg:"positional"` + Files []string `arg:"positional,required"` } type RenameCmd struct { - Files []string `arg:"positional"` + Files []string `arg:"positional,required"` } type ArtCmd struct { - Files []string `arg:"positional"` + Files []string `arg:"positional,required"` + OutputDirectory string `arg:"--output,-o" help:"where to download art files" default:"."` } type args struct { @@ -25,23 +26,14 @@ type args struct { func Run() { var args args - p := arg.MustParse(&args) + arg.MustParse(&args) switch { case args.Scan != nil: - 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: - 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: - if len(args.Art.Files) == 0 { - p.Fail("Provide at least one file to download art for") - } - oplcli.DownloadGameArt(args.Art.Files, oplcli.Config{}) + oplcli.DownloadGameArt(args.Art.Files, args.Art.OutputDirectory, oplcli.Config{}) } } diff --git a/internal/oplcli.go b/internal/oplcli.go index 9dad292..ee36a12 100644 --- a/internal/oplcli.go +++ b/internal/oplcli.go @@ -61,7 +61,7 @@ func Rename(files []string, config Config) { } } -func DownloadGameArt(files []string, config Config) { +func DownloadGameArt(files []string, output string, config Config) { for _, file := range files { fmt.Printf("Scanning file: %s\n", file) @@ -73,6 +73,6 @@ func DownloadGameArt(files []string, config Config) { fmt.Printf("Found game ID: %s\n", gameID) - downloadArtForGame(gameID, "./ignore") + downloadArtForGame(gameID, output) } }