aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2021-04-26 07:40:37 +0200
committerJan200101 <sentrycraft123@gmail.com>2021-04-26 07:40:37 +0200
commite6279af295cc0e8b985a5a43a16ac6313eb6c698 (patch)
tree52f39915b61988b784fd03495234dd75001e033e /src/main.c
parent67d5d1b742584ffeb9859eb7b92a41e0d365622d (diff)
downloadpolecat-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.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 605e1dc..5f7426d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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, "")