Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

develroot / tools / RepoInfoMain.cpp

912 B · Raw · Log

// Copyright (c) 2026 Progmasoft.
// SPDX-License-Identifier: LGPL-3.0-or-later

// bazelisk run //tools:repo_info [-- --json]
//
// Reports the checkout and the tools on PATH, without changing anything.

#include <iostream>
#include <string_view>

#include "tools/Repository.hpp"
#include "tools/RepositoryReport.hpp"

int
main(int argc, char **argv)
{
    using namespace Progmasoft::Catch3::Tools;

    const bool json = argc == 2 && std::string_view{ argv[1] } == "--json";
    if (argc > 2 || (argc == 2 && !json))
    {
        std::cerr << "usage: bazelisk run //tools:repo_info [-- --json]\n";
        return 2;
    }
    const auto root = RepositoryRoot();
    if (!root)
    {
        std::cerr << "run this tool with bazelisk run\n";
        return 2;
    }
    const auto report = CollectRepositoryReport(*root);
    std::cout << (json ? ReportToJson(report) : FormatReport(report));
    return 0;
}