src/main.cpp

changeset 3
c87bde92805f
parent 1
9bf126bc825c
child 4
82680ce258d6
--- a/src/main.cpp	Tue Jan 21 18:25:59 2025 +0100
+++ b/src/main.cpp	Tue Jan 21 20:24:45 2025 +0100
@@ -23,6 +23,7 @@
  */
 
 #include "settings.h"
+#include "repositories.h"
 
 #include <cstdlib>
 #include <cstdio>
@@ -48,13 +49,14 @@
         "When you do not specify \033[1m--no-pull\033[22m, this tool will execute the pull command\n"
         "(and for hg the update command) before retrieving the commit log, assuming\n"
         "to be on the default branch with \033[4mno uncommitted changes\033[24m.\n\n"
-        "The default output format prints an HTML page to stdout. In all cases, a\n"
-        "separate heat map is generated for each author, but all repositories are,\n"
-        "accumulated unless the \033[1m--separate\033[22m option is specified.\n"
+        "Afterwards, this tool prints an HTML page to stdout. A separate heap map is\n"
+        "generated for each author showing commits across all repositories, unless the\n"
+        "\033[1m--separate\033[22m option is specified in which case each repository is displayed with\n"
+        "its own heat map.\n"
         , stderr);
 }
 
-static bool chk_arg(const char* arg, const char* opt1, const char* opt2) {
+static bool chk_arg(const char *arg, const char *opt1, const char *opt2) {
     return strcmp(arg, opt1) == 0 || (opt2 != nullptr && strcmp(arg, opt2) == 0);
 }
 
@@ -88,7 +90,7 @@
                 return -1;
             }
         } else if (chk_arg(argv[i], "-n", "--no-pull")) {
-            settings.nopull = true;
+            settings.update_repos = false;
         } else if (chk_arg(argv[i], "-s", "--separate")) {
             settings.separate = true;
         } else if (chk_arg(argv[i], "--hg", nullptr)) {
@@ -120,6 +122,14 @@
     return 0;
 }
 
+static void print_html_header() {
+    puts("<html>\n\t<body>");
+}
+
+static void print_html_footer() {
+    puts("\t</body>\n</html>");
+}
+
 int main(int argc, char *argv[]) {
     fm::settings settings;
 
@@ -127,6 +137,18 @@
         return EXIT_FAILURE;
     }
 
+    fm::repositories repos;
+    for (auto &&path: settings.paths) {
+        repos.scan(path, settings.depth);
+    }
+    if (!settings.update_repos) {
+        // TODO: update repositories
+    }
+    // TODO: calculate the heat maps
+
+    print_html_header();
+    // TODO: output the heat maps here
+    print_html_footer();
+
     return EXIT_SUCCESS;
 }
-

mercurial