src/main.cpp

changeset 14
f0ae064c5b9c
parent 13
e714005f3e9d
child 16
730a5638c4ad
--- a/src/main.cpp	Sat Feb 01 14:19:36 2025 +0100
+++ b/src/main.cpp	Sat Feb 01 15:06:48 2025 +0100
@@ -40,13 +40,16 @@
     fputs(
         "Usage: fallusmeter [OPTION]... [PATH]...\n\n"
         "Options:\n"
-        "   -h, --help             Print this help message\n"
-        "   -d, --depth <num>      The search depth (default: 1, max: 255)\n"
-        "   -n, --no-pull          Do not pull the repositories\n"
-        "   -s, --separate         Output a separate heat map for each repository\n"
-        "   -y, --year <year>      The year for which to create the heat map\n"
-        "       --hg <path>        Path to hg binary (default: /usr/bin/hg)\n"
-        "       --git <path>       Path to git binary (default: /usr/bin/git)\n\n"
+        "   -a, --author <name>       Only report this author\n"
+        "                             (repeat option to report multiple authors)\n"
+        "   -A, --authormap <file>    Apply an author mapping file\n"
+        "   -h, --help                Print this help message\n"
+        "   -d, --depth <num>         The search depth (default: 1, max: 255)\n"
+        "   -n, --no-pull             Do not pull the repositories\n"
+        "   -s, --separate            Output a separate heat map for each repository\n"
+        "   -y, --year <year>         The year for which to create the heat map\n"
+        "       --hg <path>           Path to hg binary (default: /usr/bin/hg)\n"
+        "       --git <path>          Path to git binary (default: /usr/bin/git)\n\n"
         "Scans all specified paths recursively for Mercurial and Git repositories and\n"
         "creates a commit heat map for the specified \033[1myear\033[22m or the current year.\n"
         "By default, the recursion \033[1mdepth\033[22m is one, meaning that this tool assumes that\n"
@@ -58,7 +61,21 @@
         "an error, an error message is written to stderr and the process continues\n"
         "with the repository in its current state. This is also the case when pulling\n"
         "requires authorization.\n\n"
-        "Afterwards, this tool prints an HTML page to stdout. A separate heap map is\n"
+        "By default, this tool reports commits from all authors. If you want to include\n"
+        "only specific authors in the report, you can use the \033[1m--author\033[22m option with as\n"
+        "many authors as you like. You can specify either the full author strings with\n"
+        "name and mail address, just the mail address, or even just the local-part of\n"
+        "the mail address. In case your repository contains commits from an author who\n"
+        "used different names or mail addresses, you can use the \033[1m--authormap\033[22m option\n"
+        "to specify a file that contains pairs of author strings, like in the following\n"
+        "example:\n\n"
+        "   Full Name <full.name@example.org> = New Name <new.name@example.org>\n"
+        "   just.mail@example.org = new.name@example.org\n"
+        "   username = new.name\n\n"
+        "The different variants of full string, only mail address, and only local-part\n"
+        "can be combined as you like. When you use the \033[1m--author\033[22m option at the same\n"
+        "time, you only need to specify the new author names.\n\n"
+        "Finally, 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"
@@ -98,6 +115,13 @@
                 fputs("missing or invalid year\n", stderr);
                 return -1;
             }
+        } else if (chk_arg(argv[i], "-a", "--author")) {
+            if (i + 1 < argc) {
+                settings.authors.emplace_back(argv[++i]);
+            } else {
+                fputs("missing author name\n", stderr);
+                return -1;
+            }
         } else if (chk_arg(argv[i], "-n", "--no-pull")) {
             settings.update_repos = false;
         } else if (chk_arg(argv[i], "-s", "--separate")) {
@@ -219,6 +243,8 @@
     for (const auto &[repo, authors] : heatmap.data()) {
         html::h1(repo);
         for (const auto &[author, entries] : authors) {
+            if (settings.exclude_author(author)) continue;
+
             html::h2(author);
             html::table_begin(report_year);
 

mercurial