X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=bin%2Fmpd-feeder;h=ffb7994e2db793f5a42a3daae7f4a1714044bbf2;hb=7f5a01ffe5b4c4feb09aea13fe7cddc6c89a4ab2;hp=bc73a73aa7988ed57df18108c8281dc8d8f4f5df;hpb=5cc21bbc52af1083e7f4ecb95601878b1fa88499;p=mpd-feeder.git diff --git a/bin/mpd-feeder b/bin/mpd-feeder index bc73a73..ffb7994 100755 --- a/bin/mpd-feeder +++ b/bin/mpd-feeder @@ -11,62 +11,10 @@ use Log::Any::Adapter Stderr => log_level => 'error'; my $feeder = App::MPD::Feeder->new(); if (@ARGV) { - my $cmd = shift @ARGV; + require App::MPD::Feeder::Command; + bless $feeder, 'App::MPD::Feeder::Command'; - if ($cmd eq 'dump-config') { - die "dump-config command accepts no arguments\n" if @ARGV; - - $feeder->opt->dump; - exit; - } - - if ( $cmd eq 'add-unwanted-artist' ) { - die "Missing command arguments\n" unless @ARGV; - $feeder->set_db_needs_update(0); - for my $artist (@ARGV) { - if ( $feeder->db_add_unwanted_artist($artist) ) { - $log->info("Artist '$artist' added to the unwanted list\n"); - } - else { - $log->warn("Artist '$artist' already in the unwanted list\n"); - } - } - exit; - } - - if ( $cmd eq 'del-unwanted-artist' ) { - die "Missing command arguments\n" unless @ARGV; - $feeder->set_db_needs_update(0); - for my $artist (@ARGV) { - if ( $feeder->db_del_unwanted_artist($artist) ) { - $log->info("Artist '$artist' deleted from the unwanted list\n"); - } - else { - $log->warn("Artist '$artist' is not in the unwanted list\n"); - } - } - exit; - } - - if ( $cmd eq 'add-unwanted-album' ) { - die "NOT IMPLEMENTED\n"; - } - - if ( $cmd eq 'one-shot' ) { - die "one-shot command accepts no arguments\n" if @ARGV; - - $feeder->queue_songs(undef, sub { exit }); - $feeder->mpd->loop->run; - } - elsif ( $cmd eq 'single' ) { - die "single command accepts no arguments\n" if @ARGV; - - $feeder->queue_songs(1, sub { exit }); - $feeder->mpd->loop->run; - } - else { - die "Unknown command '$cmd'"; - } + exit $feeder->run(@ARGV); } $feeder->run_loop;