diff options
Diffstat (limited to 'src/common.c')
-rw-r--r-- | src/common.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c new file mode 100644 index 0000000..f3131e0 --- /dev/null +++ b/src/common.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <string.h> + +#include "common.h" + +void print_help(const struct Command* commands, const size_t size) +{ + int longestCommand = 0; + + for (size_t i = 0; i < size; ++i) + { + int commandLength = strlen(commands[i].name); + + if (commandLength > longestCommand) longestCommand = commandLength; + } + + for (size_t i = 0; i < size; ++i) + { + printf("\t%-*s\t%s\n", longestCommand, commands[i].name, commands[i].description); + } +} |