Some code ergonomics
This commit is contained in:
parent
d43f82d5ef
commit
ac7a86f925
@ -95,6 +95,18 @@ macro_rules! url_command_dispatch {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! single_url_command_dispatch {
|
||||||
|
($cmd:ident, $mh:ident, $add:ident, $remove:ident, $set:ident, $clear:ident) => {
|
||||||
|
url_command_dispatch!($cmd, $mh, $add, $remove, $set, $clear, url)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! multi_url_command_dispatch {
|
||||||
|
($cmd:ident, $mh:ident, $add:ident, $remove:ident, $set:ident, $clear:ident) => {
|
||||||
|
url_command_dispatch!($cmd, $mh, $add, $remove, $set, $clear, urls)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
impl ArtistCommand {
|
impl ArtistCommand {
|
||||||
fn handle(self, music_hoard: &mut MH) {
|
fn handle(self, music_hoard: &mut MH) {
|
||||||
match self {
|
match self {
|
||||||
@ -108,41 +120,37 @@ impl ArtistCommand {
|
|||||||
.delete_artist(ArtistId::new(artist_value.artist))
|
.delete_artist(ArtistId::new(artist_value.artist))
|
||||||
.expect("failed to delete artist");
|
.expect("failed to delete artist");
|
||||||
}
|
}
|
||||||
ArtistCommand::MusicBrainz(url_command) => url_command_dispatch!(
|
ArtistCommand::MusicBrainz(url_command) => single_url_command_dispatch!(
|
||||||
url_command,
|
url_command,
|
||||||
music_hoard,
|
music_hoard,
|
||||||
add_musicbrainz_url,
|
add_musicbrainz_url,
|
||||||
remove_musicbrainz_url,
|
remove_musicbrainz_url,
|
||||||
set_musicbrainz_url,
|
set_musicbrainz_url,
|
||||||
clear_musicbrainz_url,
|
clear_musicbrainz_url
|
||||||
url
|
|
||||||
),
|
),
|
||||||
ArtistCommand::MusicButler(url_command) => url_command_dispatch!(
|
ArtistCommand::MusicButler(url_command) => multi_url_command_dispatch!(
|
||||||
url_command,
|
url_command,
|
||||||
music_hoard,
|
music_hoard,
|
||||||
add_musicbutler_urls,
|
add_musicbutler_urls,
|
||||||
remove_musicbutler_urls,
|
remove_musicbutler_urls,
|
||||||
set_musicbutler_urls,
|
set_musicbutler_urls,
|
||||||
clear_musicbutler_urls,
|
clear_musicbutler_urls
|
||||||
urls
|
|
||||||
),
|
),
|
||||||
ArtistCommand::Bandcamp(url_command) => url_command_dispatch!(
|
ArtistCommand::Bandcamp(url_command) => multi_url_command_dispatch!(
|
||||||
url_command,
|
url_command,
|
||||||
music_hoard,
|
music_hoard,
|
||||||
add_bandcamp_urls,
|
add_bandcamp_urls,
|
||||||
remove_bandcamp_urls,
|
remove_bandcamp_urls,
|
||||||
set_bandcamp_urls,
|
set_bandcamp_urls,
|
||||||
clear_bandcamp_urls,
|
clear_bandcamp_urls
|
||||||
urls
|
|
||||||
),
|
),
|
||||||
ArtistCommand::Qobuz(url_command) => url_command_dispatch!(
|
ArtistCommand::Qobuz(url_command) => single_url_command_dispatch!(
|
||||||
url_command,
|
url_command,
|
||||||
music_hoard,
|
music_hoard,
|
||||||
add_qobuz_url,
|
add_qobuz_url,
|
||||||
remove_qobuz_url,
|
remove_qobuz_url,
|
||||||
set_qobuz_url,
|
set_qobuz_url,
|
||||||
clear_qobuz_url,
|
clear_qobuz_url
|
||||||
url
|
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user