option: add function to format a list of short and long options together with their respective descriptions
parent
01270673a3
commit
d2d2adacec
@ -0,0 +1,9 @@ |
||||
#pragma once |
||||
|
||||
struct opt_desc { |
||||
const char *short_name; |
||||
const char *long_name; |
||||
const char *desc; |
||||
}; |
||||
|
||||
void format_options(struct opt_desc *entries); |
@ -0,0 +1,15 @@ |
||||
#include <stdio.h> |
||||
|
||||
#include <option.h> |
||||
|
||||
void format_options(struct opt_desc *entries) |
||||
{ |
||||
struct opt_desc *entry; |
||||
|
||||
for (entry = entries; entry->long_name; ++entry) { |
||||
fprintf(stderr, "%7s %-16s %s\n", |
||||
entry->short_name ? entry->short_name : "", |
||||
entry->long_name, |
||||
entry->desc); |
||||
} |
||||
} |
Loading…
Reference in new issue