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
+36
View File
@@ -0,0 +1,36 @@
# Standalone build of the cli module, its unit test and the argparse parity driver.
# Usage (from taicpp/): make -f tests/cli.mk test
# Every output lands in build/cli.
CXX ?= g++
CXXFLAGS ?= -std=c++23 -Wall -Wextra -O1
MOLO ?= /home/retoor/projects/moloapp/src
B = build/cli
GEN = $(B)/gen
SRCS = $(wildcard src/cli/*.cpp)
INC = -Isrc/cli -I$(GEN) -I$(MOLO)
all: $(B)/cli_test $(B)/cli_driver $(B)/cli_main
$(GEN)/version.hpp: VERSION src/cli/version.hpp.in
@mkdir -p $(GEN)
@sed 's/@VERSION@/$(shell cat VERSION)/' src/cli/version.hpp.in > $@
$(B)/cli_test: tests/cli_test.cpp $(SRCS) $(GEN)/version.hpp
$(CXX) $(CXXFLAGS) $(INC) tests/cli_test.cpp $(SRCS) -o $@
$(B)/cli_driver: tests/cli_driver.cpp $(SRCS) $(GEN)/version.hpp
$(CXX) $(CXXFLAGS) $(INC) tests/cli_driver.cpp $(SRCS) -o $@
$(B)/cli_main: tests/cli_main.cpp $(SRCS) $(GEN)/version.hpp
$(CXX) $(CXXFLAGS) $(INC) tests/cli_main.cpp $(SRCS) -o $@
# Parse-only differential cases of tools/parity_diff.py against the cli-only entry point.
diff: $(B)/cli_main
python3 tools/parity_diff.py --detz $(CURDIR)/$(B)/cli_main --filter cli.
test: $(B)/cli_test $(B)/cli_driver
$(B)/cli_test
python3 tests/cli_parity.py --driver $(B)/cli_driver
clean:
rm -rf $(B)