return errors and handle os.Exit in cmd file
This commit is contained in:
@@ -2,6 +2,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"os"
|
||||
|
||||
ripsort "git.kapelle.org/niklas/ripsort/internal"
|
||||
"github.com/alexflint/go-arg"
|
||||
@@ -49,17 +50,23 @@ func Run() {
|
||||
|
||||
switch {
|
||||
case args.Info != nil:
|
||||
ripsort.Scan(args.Info.File)
|
||||
if err := ripsort.Scan(args.Info.File); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
case args.Sort != nil:
|
||||
ripsort.Sort(args.Sort.Dst, args.Sort.Path)
|
||||
if err := ripsort.Sort(args.Sort.Dst, args.Sort.Path); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
case args.SyncPlaylists != nil:
|
||||
ripsort.SyncPlaylists(
|
||||
if err := ripsort.SyncPlaylists(
|
||||
args.SyncPlaylists.SpotifyClientID,
|
||||
args.SyncPlaylists.SpotifyClientSecret,
|
||||
args.SyncPlaylists.NavidromeURL,
|
||||
args.SyncPlaylists.NavidromeUser,
|
||||
args.SyncPlaylists.NavidromePass,
|
||||
)
|
||||
); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
default:
|
||||
p.Fail("Must specify command")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user