allow for setting host and port with command line switches

master
Andrzej Rybczak 17 years ago
parent 25f0b4fabc
commit 1daa41bde6
  1. 6
      doc/ncmpcpp.1
  2. 18
      src/helpers.cpp

@ -9,6 +9,12 @@ ncmpcpp is an ncurses client for MPD (Music Player Daemon), inspired by ncmpc.
Read more about MPD at http://www.musicpd.org
.SH "OPTIONS"
.B \-h
Connect to server at host [localhost]
.TP
.B \-?, \-\-help
Connect to server at port [6600]
.TP
.B \-?, \-\-help
Display help.
.TP

@ -53,7 +53,21 @@ void ParseArgv(int argc, char **argv)
for (int i = 1; i < argc; i++)
{
if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0)
if (strcmp(argv[i], "-h") == 0)
{
if (++i >= argc)
exit(0);
Mpd->SetHostname(argv[i]);
continue;
}
if (strcmp(argv[i], "-p") == 0)
{
if (++i >= argc)
exit(0);
Mpd->SetPort(atoi(argv[i]));
continue;
}
else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0)
{
cout << "ncmpcpp version: " << VERSION << endl
<< "built with support for:"
@ -73,6 +87,8 @@ void ParseArgv(int argc, char **argv)
{
cout
<< "Usage: ncmpcpp [OPTION]...\n"
<< " -h connect to server at host [localhost]\n"
<< " -p connect to server at port [6600]\n"
<< " -?, --help show this help message\n"
<< " -v, --version display version information\n\n"
<< " play start playing\n"

Loading…
Cancel
Save