Skip to content

Commit 6c5deb6

Browse files
author
xcinnay
committed
Add -h option that display usage. Correct few man and makefile typographic mistakes.
1 parent 7317f1b commit 6c5deb6

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ all : $(OUT)
4242

4343
check_deps :
4444
pkg-config --cflags glib-2.0
45-
pkg-config --cflags ppppurple
45+
pkg-config --cflags purple
4646
@echo "- depandancies OK"
4747

4848
clean :

purpled.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,6 +1449,21 @@ handle_server_signals(int sig)
14491449
}
14501450
}
14511451

1452+
void print_usage(void)
1453+
{
1454+
fprintf(stderr, "Usage: purpled [-d] [-pPORT] [-lLISTEN_IP]\n"
1455+
"OPTIONS\n"
1456+
"-d run purpled a unix daemon\n"
1457+
"-pPORT specify on which TCP port purpled listen. Default: 32000\n"
1458+
"-lLISTEN_IP specify on which IP address purpled listen. Default: any 0.0.0.0\n"
1459+
"-h display this help and exit\n\n"
1460+
"EXAMPLES\n"
1461+
"purpled, listen on port 4242 and stay in the terminal.\n"
1462+
" $ purpled -p4242\n"
1463+
"purpled, listen on IP address 127.0.0.1 and start as a deamon.\n"
1464+
" $ purpled -l127.0.0.1 -d\n");
1465+
}
1466+
14521467
int main(int argc, char *argv[])
14531468
{
14541469
char *param;
@@ -1469,11 +1484,17 @@ int main(int argc, char *argv[])
14691484
{
14701485
run_as_daemon = TRUE;
14711486
}
1487+
else if (param[1] == 'h')
1488+
{
1489+
print_usage();
1490+
return (EXIT_SUCCESS);
1491+
}
14721492
else if (param[1] == 'l')
14731493
{
14741494
if (!inet_aton (&param[2], &listen_addr))
14751495
{
14761496
fprintf(stderr, "invalid listen address: %s\n", &param[2]);
1497+
print_usage();
14771498
return (EXIT_FAILURE);
14781499
}
14791500
}
@@ -1484,6 +1505,7 @@ int main(int argc, char *argv[])
14841505
if ((port <= 1) || (port > 66536))
14851506
{
14861507
fprintf(stderr, "invalid listen port: %s\n", &param[2]);
1508+
print_usage();
14871509
return (EXIT_FAILURE);
14881510
}
14891511
else
@@ -1494,12 +1516,14 @@ int main(int argc, char *argv[])
14941516
else
14951517
{
14961518
fprintf(stderr, "unknown parameter: %s\n", param);
1519+
print_usage();
14971520
return (EXIT_FAILURE);
14981521
}
14991522
}
15001523
else
15011524
{
15021525
fprintf(stderr, "invalid parameter: %s\n", param);
1526+
print_usage();
15031527
return (EXIT_FAILURE);
15041528
}
15051529
}

purpled.man

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,24 @@ specify on which IP address purpled listen.
4646

4747
Default: any 0.0.0.0
4848

49+
.TP
50+
51+
.B -h
52+
display usage and exit.
53+
4954
.SH EXAMPLES
5055

5156
purpled, listen on port 4242 and stay in the terminal.
5257

5358
.HP
5459

55-
$ purple -p4242
60+
$ purpled -p4242
5661

5762
purpled, listen on IP address 127.0.0.1 and start as a deamon.
5863

5964
.HP
6065

61-
$ purple -l127.0.0.1 -d
66+
$ purpled -l127.0.0.1 -d
6267

6368
.SH COMMANDS
6469

@@ -99,7 +104,7 @@ Lists all accounts and their states.
99104

100105
.TP
101106

102-
.B accound ID
107+
.B account ID
103108

104109
Multi-purpose command to perform an operation on an account.
105110
ID either specifies index number from "account list" output,
@@ -110,6 +115,12 @@ index number will be selected, and the others - neglected.
110115

111116
.TP
112117

118+
.B account ID set alias ALIAS
119+
120+
define an alias for the account which can be used instead of ID
121+
122+
.TP
123+
113124
.B account ID up
114125

115126
Go online.

0 commit comments

Comments
 (0)