Move print helper functions to arg_parse.h
These functions have more to do with commands, and it will be more helpful to have the print_help function especially in the same file as the actual commands structure.
This commit is contained in:
parent
9bc45d634e
commit
cf1a40c2fe
@ -17,6 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
enum cmd_id {
|
enum cmd_id {
|
||||||
CMD_UNKNOWN = 0,
|
CMD_UNKNOWN = 0,
|
||||||
CMD_HELP,
|
CMD_HELP,
|
||||||
@ -33,4 +35,23 @@ static const struct cmd commands[] = {
|
|||||||
{ CMD_VERSION, {"version", "-v", "--version"} },
|
{ CMD_VERSION, {"version", "-v", "--version"} },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline void print_version(void) {
|
||||||
|
printf("menu-helper v%s\n\n", VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void print_usage(void) {
|
||||||
|
printf("USAGE: menu-helper <cmd> [options]\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void print_help(void) {
|
||||||
|
print_version();
|
||||||
|
print_usage();
|
||||||
|
|
||||||
|
printf("COMMANDS:\n"
|
||||||
|
"\thelp, -h, --help Show this help information.\n"
|
||||||
|
"\tversion, -v, --version Show version information.\n"
|
||||||
|
"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
enum cmd_id parse_args(const char *cmd);
|
enum cmd_id parse_args(const char *cmd);
|
||||||
|
18
src/main.c
18
src/main.c
@ -20,24 +20,6 @@
|
|||||||
|
|
||||||
#include "arg_parse.h"
|
#include "arg_parse.h"
|
||||||
|
|
||||||
void print_version(void) {
|
|
||||||
printf("menu-helper v%s\n\n", VERSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_usage(void) {
|
|
||||||
printf("USAGE: menu-helper <cmd> [options]\n\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_help(void) {
|
|
||||||
print_version();
|
|
||||||
print_usage();
|
|
||||||
|
|
||||||
printf("COMMANDS:\n"
|
|
||||||
"\thelp, -h, --help Show this help information.\n"
|
|
||||||
"\tversion, -v, --version Show version information.\n"
|
|
||||||
"\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
enum cmd_id id;
|
enum cmd_id id;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user