configuration: bring back --now-playing (under a different name)

This commit is contained in:
Andrzej Rybczak
2015-09-12 21:49:44 +02:00
parent a94e620f29
commit 72cfd27c30
2 changed files with 15 additions and 0 deletions

1
NEWS
View File

@@ -30,6 +30,7 @@ ncmpcpp-0.7 (????-??-??)
* Tracks in media library are now properly sorted for track numbers greater than 99.
* Value of 'visualizer_sync_interval' is now restricted to be greater than 9.
* Output of the visualizer now scales automatically as long as 'visualizer_sample_multiplier' is set to 1.
* Command line switch that prints current song to the standard output is available once again.
ncmpcpp-0.6.6 (2015-09-07)
* A typo in the example configuration file was fixed.

View File

@@ -77,6 +77,7 @@ bool configure(int argc, char **argv)
options.add_options()
("host,h", po::value<std::string>()->default_value("localhost"), "connect to server at host")
("port,p", po::value<int>()->default_value(6600), "connect to server at port")
("current-song", po::value<std::string>()->implicit_value("{{{(%l) }{{%a - }%t}}|{%f}}"), "print current song using given format and exit")
("config,c", po::value<std::vector<std::string>>(&config_paths)->default_value(default_config_paths, join<std::string>(default_config_paths, " AND ")), "specify configuration file(s)")
("ignore-config-errors", "ignore unknown and invalid options in configuration files")
("bindings,b", po::value<std::string>(&bindings_path)->default_value("~/.ncmpcpp/bindings"), "specify bindings file")
@@ -186,6 +187,19 @@ bool configure(int argc, char **argv)
Mpd.SetPort(vm["port"].as<int>());
Mpd.SetTimeout(Config.mpd_connection_timeout);
// print current song
if (vm.count("current-song"))
{
Mpd.Connect();
auto s = Mpd.GetCurrentSong();
if (!s.empty())
{
auto format = Format::parse(vm["current-song"].as<std::string>(), Format::Flags::Tag);
std::cout << Format::stringify<char>(format, &s);
return false;
}
}
// custom startup screen
if (vm.count("screen"))
{