about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-12-07 16:58:09 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-12-07 16:58:09 +0100
commit377a7b8e83f6d96e66801cc381f783bd14fd49ca (patch)
treeb25cc8ed1fc45032745c4e617a127f7d4c50a5f0 /src
parentc833bd7feaaaec3f9a5e8e48bba3df7aa521189f (diff)
downloadprofani-tty-377a7b8e83f6d96e66801cc381f783bd14fd49ca.tar.gz
Generate date for manpage
Diffstat (limited to 'src')
-rw-r--r--src/command/cmd_defs.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index beaabac7..fba0e89e 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -2846,6 +2846,16 @@ command_mangen(void)
 
     mkdir_recursive("docs");
 
+    char* header = NULL;
+    GDateTime *now = g_date_time_new_now_local();
+    gchar *date = g_date_time_format(now, "%F");
+    if (asprintf(&header, ".TH man 1 \"%s\" \""PACKAGE_VERSION"\" \"Profanity XMPP client\"\n", date) == -1) {
+        // TODO: error
+        return;
+    }
+    g_date_time_unref(now);
+    g_free(date);
+
     GList* curr = cmds;
     while (curr) {
         Command* pcmd = curr->data;
@@ -2858,7 +2868,7 @@ command_mangen(void)
         FILE* manpage = fopen(filename, "w");
         free(filename);
 
-        fputs(".TH man 1 \"2020-07-01\" \""PACKAGE_VERSION"\" \"Profanity XMPP client\"\n", manpage);
+        fprintf(manpage, "%s\n", header);
         fputs(".SH NAME\n", manpage);
         fprintf(manpage, "%s\n", pcmd->cmd);
 
@@ -2891,11 +2901,12 @@ command_mangen(void)
             }
         }
 
-        curr = g_list_next(curr);
-
         fclose(manpage);
+        curr = g_list_next(curr);
     }
 
     printf("\nProcessed %d commands.\n\n", g_list_length(cmds));
+
+    free(header);
     g_list_free(cmds);
 }