summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2021-02-24 23:35:55 +0100
committerAki <please@ignore.pl>2021-02-24 23:35:55 +0100
commitf2214f3ff4c11d0d7c6890547dd36cd15ac72e3d (patch)
treefde1ae808f44908e1c65603ba6b7f13603d8d9b6
parentcfeb0c196655f3cb8afa200eebc443fa12961552 (diff)
downloadplop-f2214f3ff4c11d0d7c6890547dd36cd15ac72e3d.zip
plop-f2214f3ff4c11d0d7c6890547dd36cd15ac72e3d.tar.gz
plop-f2214f3ff4c11d0d7c6890547dd36cd15ac72e3d.tar.bz2
Added help CLI option
-rw-r--r--main.c12
-rw-r--r--plop.17
2 files changed, 16 insertions, 3 deletions
diff --git a/main.c b/main.c
index 3587c56..bc4993d 100644
--- a/main.c
+++ b/main.c
@@ -11,10 +11,11 @@
static void usage(const char * const name)
{
dprintf(2,
- "Usage: %s [-p PORT] [HANDLER]\n"
+ "Usage: %s [-p PORT] [-h] [HANDLER]\n"
"Starts plop server listening on PORT and serving HANDLER.\n"
"HANDLER defaults to '" PLOP_DEFAULT_HANDLER "'.\n\n"
- " -p\tstart listening on PORT (default: 8080)\n",
+ " -p\tstart listening on PORT (default: 8080)\n"
+ " -h\tprints this help message\n",
name);
}
@@ -27,7 +28,7 @@ int main(int argc, char ** argv)
const char * service = "8080";
int opt;
- while (-1 != (opt = getopt(argc, argv, "p:")))
+ while (-1 != (opt = getopt(argc, argv, "p:h")))
{
switch (opt)
{
@@ -36,6 +37,11 @@ int main(int argc, char ** argv)
service = optarg;
break;
}
+ case 'h':
+ {
+ usage(argv[0]);
+ return 0;
+ }
default:
{
usage(argv[0]);
diff --git a/plop.1 b/plop.1
index 36aedb2..3c9b4df 100644
--- a/plop.1
+++ b/plop.1
@@ -4,6 +4,7 @@ plop \- Small hackable standalone engine for Lua web applications
.SH SYNOPSIS
.SY plop
.OP \-p PORT
+.OP \-h
.RI [ HANDLER ]
.YS
.SH DESCRIPTION
@@ -27,3 +28,9 @@ was used with module name
.B handler
and the return value is set as global variable with the same name. Loaded script is expected to return a function which
will be used to handle each request.
+.P
+If
+.B \-h
+option is used a short help message is printed out to standard error output, and then program is terminated. This short
+message contains default value of
+.IR HANDLER .