diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2020-07-30 01:57:26 +0200 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2020-07-30 01:57:26 +0200 |
commit | 8bdba8891071110fe3f04de81dbe375c9c1caa80 (patch) | |
tree | d29a9f4220e351a0f5dd5b4a028af9b76cc16203 /src/common.c | |
download | polecat-8bdba8891071110fe3f04de81dbe375c9c1caa80.tar.gz polecat-8bdba8891071110fe3f04de81dbe375c9c1caa80.zip |
Initial commit0.1.0
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); + } +} |