limb 0.2.0

2024-01-09

getcommandordie(3)
limb manual
getcommandordie(3)

NAME

getcommandordie - parse command's name and return the corresponding struct command

SYNOPSIS

#include <limb/command.h>
struct command *getcommandordie(int exit, const char *usage, const char *arg)

DESCRIPTION

The getcommandordie() function will read the string arg to find the matching command, using the commands array as described in command.h(0). It needs not to be an exact match, partial match are valid so long as they are unique. For more, refer to byte_get_match(3).

If no command matched the given arg, or more than one did, a warning is emitted (through the warn(3) family of functions) and dieusage(3) is called with the given exit and usage arguments to terminate process execution.

If a command matched, its corresponding structure (from the commands array) is returned.

RETURN VALUE

The getcommandordie() returns a pointer to the matching struct command for the name in arg is there is only one.

Otherwise it does not return but terminates process execution through dieusage(3).

limb 0.1.0
2023-07-24
getcommandordie(3)