Skip to content

Commit

Permalink
add command 'tags'
Browse files Browse the repository at this point in the history
  • Loading branch information
ericyape committed Dec 31, 2024
1 parent c91c08f commit 99b44b4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
0.36 (not yet released)
* add command "tags"

0.35 (2023/12/21)
* fix null pointer dereference on bad status format
Expand Down
2 changes: 2 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ Database Commands

mpc list album group artist

:command:`tags` - display all MPD tags known by the mpc client

:command:`stats` - Displays statistics about MPD.

:command:`update [\-\-wait] [<path>]` - Scans for updated files in the
Expand Down
15 changes: 15 additions & 0 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,21 @@ cmd_load(int argc, char **argv, struct mpd_connection *conn)
return 0;
}

int
cmd_tags(gcc_unused int argc, gcc_unused char **argv, gcc_unused struct mpd_connection *conn)
{
const char *name = NULL;

for (unsigned i = 0; i < MPD_TAG_COUNT; i++) {
name = mpd_tag_name(i);
if (name != NULL) {
printf("%s\n", name);
}
}

return 0;
}

int
cmd_list(int argc, char **argv, struct mpd_connection *conn)
{
Expand Down
3 changes: 3 additions & 0 deletions src/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@ cmd_waitmessage(int argc, char **argv, struct mpd_connection *conn);
int
cmd_subscribe(int argc, char **argv, struct mpd_connection *conn);

int
cmd_tags(int argc, char **argv, struct mpd_connection *conn);

#endif /* COMMAND_H */
1 change: 1 addition & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ static const struct command {
{"stop", 0, 0, 0, cmd_stop, "", "Stop playback"},
{"subscribe", 1, 1, 0, cmd_subscribe, "<channel>", "Subscribe to the specified channel and continuously receive messages." },
{"tab", 1, 1, 0, cmd_tab, "<path>", NULL},
{"tags", 0, 0, 0, cmd_tags, "", "Display all MPD tags known by the mpc client" },
{"toggle", 0, 0, 0, cmd_toggle, "", "Toggles Play/Pause, plays if stopped"},
{"toggleoutput", 1, -1, 0, cmd_toggle_output, "<output # or name> [...]", "Toggle output(s)"},
{"unmount", 1, 1, 0, cmd_unmount, "<mount-path>", "Remove a mount." },
Expand Down

0 comments on commit 99b44b4

Please sign in to comment.