48 lines
1005 B
Go
48 lines
1005 B
Go
package cmd
|
|
|
|
import (
|
|
oplcli "git.kapelle.org/niklas/opl-cli/internal"
|
|
"github.com/alexflint/go-arg"
|
|
)
|
|
|
|
type ScanCmd struct {
|
|
Files []string `arg:"positional"`
|
|
}
|
|
|
|
type RenameCmd struct {
|
|
Files []string `arg:"positional"`
|
|
}
|
|
|
|
type ArtCmd struct {
|
|
Files []string `arg:"positional"`
|
|
}
|
|
|
|
type args struct {
|
|
Scan *ScanCmd `arg:"subcommand:scan"`
|
|
Rename *RenameCmd `arg:"subcommand:rename"`
|
|
Art *ArtCmd `arg:"subcommand:art"`
|
|
}
|
|
|
|
func Run() {
|
|
var args args
|
|
p := 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{})
|
|
}
|
|
}
|