cli: faithful argparse port (single flag table, HelpFormatter, textwrap, abbreviations, usage on error)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-25 07:02:03 +01:00
co-authored by Claude Sonnet 5.5
parent f44e505b0f
commit c8f6818997
16 changed files with 1268 additions and 139 deletions
+14
View File
@@ -0,0 +1,14 @@
// Minimal detz entry point over the cli module only, so tools/parity_diff.py can run the
// parse-only cases (tests/diff/cases/cli_generated.json) without the full binary.
// It mirrors the first lines of main.cpp (error, version) and then Command::run.
#include <cstdio>
#include <string>
#include "../src/cli/cli.h"
#include "version.hpp"
int main(int argc, char** argv) {
detz::cli::Parser p;
auto cmd = p.parse(argc, argv);
if (!cmd.opts.error.empty()) { std::fputs((cmd.opts.error + "\n").c_str(), stderr); return 2; }
if (cmd.opts.version) { std::puts(("tai " + std::string(detz::kVersion)).c_str()); return 0; }
return cmd.run();
}