allow for setting host and port with command line switches

This commit is contained in:
Andrzej Rybczak
2009-03-26 21:50:36 +01:00
parent 25f0b4fabc
commit 1daa41bde6
2 changed files with 23 additions and 1 deletions

View File

@@ -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

View File

@@ -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"