Esempio n. 1
0
gboolean
cli_current (cli_context_t *ctx, command_t *cmd)
{
	status_entry_t *status;
	const gchar *format;
	gint refresh;

	if (!command_flag_int_get (cmd, "refresh", &refresh)) {
		refresh = 0;
	}

	if (!command_flag_string_get (cmd, "format", &format)) {
		configuration_t *config = cli_context_config (ctx);
		format = configuration_get_string (config, "STATUS_FORMAT");
	}

	status = currently_playing_init (ctx, format, refresh);

	if (refresh > 0) {
		cli_context_status_mode (ctx, status);
	} else {
		status_refresh (status, TRUE, TRUE);
		status_free (status);
	}

	return refresh != 0; /* need I/O if we are refreshing */
}
/* Extract the flag value as a list of string items.
 * Warning: the resulting string must be freed using g_strfreev() !*/
gboolean
command_flag_stringlist_get (command_context_t *ctx, const gchar *name, const gchar ***v)
{
	const gchar *full;
	gboolean retval = FALSE;

	if (command_flag_string_get (ctx, name, &full) && full) {
		/* Force cast to suppress warning, Don't panic! */
		*v = (const gchar **) g_strsplit (full, ",", MAX_STRINGLIST_TOKENS);
		retval = TRUE;
	}

	return retval;
}