Also: move displaying the help message to a separate function.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
static const char *const shortopts = "+h";
+static void print_help(void)
+{
+ printf("Usage: %s <options> [NAME]\n", get_progname());
+ printf("Find a GPIO line by name.\n");
+ printf("Options:\n");
+ printf(" -h, --help:\t\tdisplay this message and exit\n");
+}
+
int main(int argc, char **argv)
{
struct gpiod_line *line;
switch (optc) {
case 'h':
- printf("Usage: %s [NAME]\n", get_progname());
- printf("Find a GPIO line by name.\n");
+ print_help();
exit(EXIT_SUCCESS);
case '?':
die("try %s --help", get_progname());