Commit Diff


commit - 19ae7661fba68233ba50e4ddf9f227c064b75ad2
commit + 8e916714790046deccff6075357dc4fef087e9b4
blob - 125dcb5691c49f790f814ec0600aaf9d2d9c8881
blob + f1a5b2aefd895341494689f892fcfd26a573be9c
--- amused.1
+++ amused.1
@@ -68,8 +68,14 @@ Rewind the current song from the beginning.
 Enqueue the given files.
 .It Cm flush
 Erase the playlist.
-.It Cm show
+.It Cm show Op Fl p
 Print the current playlist.
+With
+.Fl p
+it prints a
+.Dq pretty
+list with the current playing song prefixed by
+.Sq > \&
 .It Cm status
 Print playback status and current song.
 .It Cm next
blob - e84265e2e63261847f752998621a9686b65f1344
blob + 7fc31cbfd0f2d91692dacf5e22367df7c3f7cf88
--- amused.h
+++ amused.h
@@ -81,6 +81,7 @@ struct parse_result {
 	enum actions		 action;
 	char			**files;
 	FILE			*file;
+	int			 pretty;
 	struct ctl_command	*ctl;
 };
 
blob - 7b8732b5d739d7950c2738af312d6a7181ea2bab
blob + 54e4638102a566d2c5438430fcdf8eb15e0d9401
--- ctl.c
+++ ctl.c
@@ -41,6 +41,7 @@ static struct imsgbuf *ibuf;
 
 int	ctl_noarg(struct parse_result *, int, char **);
 int	ctl_add(struct parse_result *, int, char **);
+int	ctl_show(struct parse_result *, int, char **);
 int	ctl_load(struct parse_result *, int, char **);
 
 struct ctl_command ctl_commands[] = {
@@ -51,7 +52,7 @@ struct ctl_command ctl_commands[] = {
 	{ "restart",	RESTART,	ctl_noarg,	"" },
 	{ "add",	ADD,		ctl_add,	"files...", 1 },
 	{ "flush",	FLUSH,		ctl_noarg,	"" },
-	{ "show",	SHOW,		ctl_noarg,	"" },
+	{ "show",	SHOW,		ctl_show,	"" },
 	{ "status",	STATUS,		ctl_noarg,	"" },
 	{ "next",	NEXT,		ctl_noarg,	"" },
 	{ "prev",	PREV,		ctl_noarg,	"" },
@@ -175,7 +176,7 @@ show_add(struct imsg *imsg, int *ret, char ***files)
 }
 
 static int
-show_complete(struct imsg *imsg, int *ret)
+show_complete(struct parse_result *res, struct imsg *imsg, int *ret)
 {
 	struct player_status s;
 	size_t datalen;
@@ -196,7 +197,9 @@ show_complete(struct imsg *imsg, int *ret)
 	if (s.path[sizeof(s.path)-1] != '\0')
 		fatalx("%s: data corrupted?", __func__);
 
-	printf("%s %s\n", s.status == STATE_PLAYING ? ">" : " ", s.path);
+	if (res->pretty)
+		printf("%c ", s.status == STATE_PLAYING ? '>' : ' ');
+	printf("%s\n", s.path);
 	return 0;
 }
 
@@ -382,7 +385,7 @@ ctlaction(struct parse_result *res)
 				done = show_add(&imsg, &ret, &files);
 				break;
 			case SHOW:
-				done = show_complete(&imsg, &ret);
+				done = show_complete(res, &imsg, &ret);
 				break;
 			case STATUS:
 				done = show_status(&imsg, &ret);
@@ -425,6 +428,24 @@ ctl_add(struct parse_result *res, int argc, char **arg
 }
 
 int
+ctl_show(struct parse_result *res, int argc, char **argv)
+{
+	int ch;
+
+	while ((ch = getopt(argc, argv, "p")) != -1) {
+		switch (ch) {
+		case 'p':
+			res->pretty = 1;
+			break;
+		default:
+			ctl_usage(res->ctl);
+		}
+	}
+
+	return ctlaction(res);
+}
+
+int
 ctl_load(struct parse_result *res, int argc, char **argv)
 {
 	if (argc < 2)