summaryrefslogtreecommitdiff
path: root/servicecmd/servicecmd.h
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-03-25 01:59:38 +0100
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-03-25 01:59:38 +0100
commitb9d829bc9abe0f5ce0234475505b33fe5b942cb4 (patch)
tree62254553207ba3af0e11e5a4bc3b19407cc4cf2a /servicecmd/servicecmd.h
parentf97add9041c7cf330d2743b1dca9267676bdaa72 (diff)
Cleanup command error handling in "service"
- Add helper for checking number of arguments - Add helper for printing "please read help" message Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'servicecmd/servicecmd.h')
-rw-r--r--servicecmd/servicecmd.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/servicecmd/servicecmd.h b/servicecmd/servicecmd.h
index 27204d0..b839799 100644
--- a/servicecmd/servicecmd.h
+++ b/servicecmd/servicecmd.h
@@ -61,6 +61,21 @@ extern command_t *commands;
void usage(int status) NORETURN;
/*
+ Write a message to stderr that advises the user how to consult the
+ help text for a specific command.
+*/
+void tell_read_help(const char *cmd);
+
+/*
+ Check if the argument count is within specified bounds (minc and maxc
+ inclusive). If it is, return 0.
+
+ If it isn't, complain about a wrong number of arguments for a
+ command (cmd), tell the user to consult the help text and return -1.
+*/
+int check_arguments(const char *cmd, int argc, int minc, int maxc);
+
+/*
To implement a new command, add a global, static instance of a
command_t (or derived) structure to a C file and pass it to this
macro to have it automatically registered on program startup.