diff options
author | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-03-25 01:59:38 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-03-25 01:59:38 +0100 |
commit | b9d829bc9abe0f5ce0234475505b33fe5b942cb4 (patch) | |
tree | 62254553207ba3af0e11e5a4bc3b19407cc4cf2a /servicecmd/servicecmd.h | |
parent | f97add9041c7cf330d2743b1dca9267676bdaa72 (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.h | 15 |
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. |