1 package App::MPD::Feeder::Command;
11 class App::MPD::Feeder::Command
12 isa App::MPD::Feeder {
14 my $cmd = shift @args;
16 if ( $cmd eq 'dump-config' ) {
17 die "dump-config command accepts no arguments\n" if @args;
24 if ( $cmd eq 'add-unwanted-artist' ) {
25 die "Missing command arguments\n" unless @args;
26 $self->set_db_needs_update(0);
27 for my $artist (@args) {
28 if ( $self->db->add_unwanted_artist($artist) ) {
30 "Artist '$artist' added to the unwanted list\n");
34 "Artist '$artist' already in the unwanted list\n");
41 if ( $cmd eq 'del-unwanted-artist' ) {
42 die "Missing command arguments\n" unless @args;
43 $self->set_db_needs_update(0);
44 for my $artist (@args) {
45 if ( $self->db->del_unwanted_artist($artist) ) {
47 "Artist '$artist' deleted from the unwanted list\n");
51 "Artist '$artist' is not in the unwanted list\n");
58 if ( $cmd eq 'list-unwanted-artists' ) {
59 die "This command has no arguments\n" if @args;
60 $self->set_db_needs_update(0);
61 my $count = $self->db->walk_unwanted_artists( sub { say @_ } );
62 say "Total unwanted artists: $count";
67 if ( $cmd eq 'add-unwanted-album' ) {
68 die "NOT IMPLEMENTED\n";
71 if ( $cmd eq 'one-shot' ) {
72 die "one-shot command accepts no arguments\n" if @args;
74 $self->queue_songs( undef, sub {$self->mpd->loop->stop} );
75 $self->mpd->loop->run;
78 elsif ( $cmd eq 'single' ) {
79 die "single command accepts no arguments\n" if @args;
81 $self->queue_songs( 1, sub {$self->mpd->loop->stop} );
82 $self->mpd->loop->run;
86 die "Unknown command '$cmd'";