Files
ripsort/cmd/ripsort.go
2026-05-02 23:56:33 +02:00

57 lines
1.3 KiB
Go

package cmd
import (
"log/slog"
ripsort "git.kapelle.org/niklas/ripsort/internal"
"github.com/alexflint/go-arg"
)
type InfoCmd struct {
File string `arg:"positional,required"`
}
type SortCmd struct {
Dst string `arg:"positional,required"`
Path string `arg:"positional,required"`
}
type SyncPlaylists struct {
Url string `arg:"positional,required"`
}
type FixCommentCmd struct {
Path string `arg:"positional,required"`
}
type args struct {
Info *InfoCmd `arg:"subcommand:info"`
Sort *SortCmd `arg:"subcommand:sort"`
FixCommentTag *FixCommentCmd `arg:"subcommand:fix-comment"`
SyncPlaylists *SyncPlaylists `arg:"subcommand:spotify"`
Verbose bool `arg:"-v" default:"false"`
DryRun bool `arg:"--dry-run" default:"false"`
}
func Run() {
var args args
p := arg.MustParse(&args)
if args.Verbose {
slog.SetLogLoggerLevel(slog.LevelDebug)
}
switch {
case args.Info != nil:
ripsort.Scan(args.Info.File)
case args.Sort != nil:
ripsort.Sort(args.Sort.Dst, args.Sort.Path)
case args.FixCommentTag != nil:
ripsort.FixComment(args.FixCommentTag.Path, args.DryRun)
case args.SyncPlaylists != nil:
ripsort.SyncPlaylists(args.SyncPlaylists.Url)
default:
p.Fail("Must specify command")
}
}