diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2021-04-26 07:40:37 +0200 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2021-04-26 07:40:37 +0200 |
commit | e6279af295cc0e8b985a5a43a16ac6313eb6c698 (patch) | |
tree | 52f39915b61988b784fd03495234dd75001e033e /src/main.c | |
parent | 67d5d1b742584ffeb9859eb7b92a41e0d365622d (diff) | |
download | polecat-e6279af295cc0e8b985a5a43a16ac6313eb6c698.tar.gz polecat-e6279af295cc0e8b985a5a43a16ac6313eb6c698.zip |
implement flags and sort commands by alphabet
stupid standard --help and --version
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -17,6 +17,10 @@ static const struct Command main_commands[] = { { .name = "env", .func = main_env, .description = "show some information about polecat" }, }; +static const struct Flag main_flags[] = { + { .name = "help", .variant = DOUBLE, .func = main_help, .description = "show this message"}, + { .name = "version", .variant = BOTH, .func = main_version, .description = "prints the program version"} +}; COMMAND_GROUP_FUNC(main) @@ -25,10 +29,7 @@ COMMAND(main, env) char buffer[PATH_MAX]; - printf("version:\t\t%s\n" - "user-Agent:\t\t%s\n", - VERSION, - USER_AGENT); + printf("user-Agent:\t\t%s\n", USER_AGENT); getConfigDir(buffer, sizeof(buffer)); printf("config dir\t\t%s\n", buffer); @@ -40,4 +41,11 @@ COMMAND(main, env) return 0; } +COMMAND(main, version) +{ + puts(VERSION); + + return 0; +} + COMMAND_HELP(main, "") |