4 class App::MPD::Feeder::Command
5 :isa(App::MPD::Feeder);
10 my $cmd = shift @args;
12 if ( $cmd eq 'dump-config' ) {
13 die "dump-config command accepts no arguments\n" if @args;
20 if ( $cmd eq 'add-unwanted-artist' ) {
21 die "Missing command arguments\n" unless @args;
22 $self->set_db_needs_update(0);
23 for my $artist (@args) {
24 if ( $self->db->add_unwanted_artist($artist) ) {
26 "Artist '$artist' added to the unwanted list\n");
30 "Artist '$artist' already in the unwanted list\n");
37 if ( $cmd eq 'del-unwanted-artist' ) {
38 die "Missing command arguments\n" unless @args;
39 $self->set_db_needs_update(0);
40 for my $artist (@args) {
41 if ( $self->db->del_unwanted_artist($artist) ) {
43 "Artist '$artist' deleted from the unwanted list\n");
47 "Artist '$artist' is not in the unwanted list\n");
54 if ( $cmd eq 'list-unwanted-artists' ) {
55 die "This command has no arguments\n" if @args;
56 $self->set_db_needs_update(0);
57 my $count = $self->db->walk_unwanted_artists( sub { say @_ } );
58 say "Total unwanted artists: $count";
63 if ( $cmd eq 'add-unwanted-album' ) {
65 "Syntax: mpd-feeder add-unwanted-album «album name» by «artist name»\n"
66 unless @args == 3 and $args[1] =~ /^by$/i;
67 $self->set_db_needs_update(0);
68 my ( $album, $artist ) = @args[ 0, 2 ];
69 if ( $self->db->add_unwanted_album( $album, $artist ) ) {
71 "Album «$album» by «$artist» added to the unwanted list\n"
76 "Album «$album» by «$artist» already in the unwanted list\n"
83 if ( $cmd eq 'del-unwanted-album' ) {
85 "Syntax: mpd-feeder del-unwanted-album «album name» by «artist name»\n"
86 unless @args == 3 and $args[1] =~ /^by$/i;
87 $self->set_db_needs_update(0);
88 my ( $album, $artist ) = @args[ 0, 2 ];
89 if ( $self->db->del_unwanted_album( $album, $artist ) ) {
91 "Album «$album» by «$artist» deleted from the unwanted list\n"
96 "Album «$album» by «$artist» is not in the unwanted list\n"
103 if ( $cmd eq 'list-unwanted-albums' ) {
104 die "This command has no arguments\n" if @args;
105 $self->set_db_needs_update(0);
106 my $count = $self->db->walk_unwanted_albums(
107 sub ( $album, $artist ) { say "«$album» by «$artist»" } );
108 say "Total unwanted albums: $count";
113 if ( $cmd eq 'one-shot' ) {
114 die "one-shot command accepts no arguments\n" if @args;
116 $self->queue_songs( undef, sub {$self->mpd->loop->stop} );
117 $self->mpd->loop->run;
120 elsif ( $cmd eq 'single' ) {
121 die "single command accepts no arguments\n" if @args;
123 $self->queue_songs( 1, sub {$self->mpd->loop->stop} );
124 $self->mpd->loop->run;
128 die "Unknown command '$cmd'";