Turn any technical book PDF into a Claude Code skill — ready to study, reference, and use while you work.
Python agent-skillsai-agentsbook-to-skillcontext-engineeringdocument-processingedtechknowledge-baseknowledge-managementllmpdf-to-markdownragself-studystudy-tools
fix(cli): support documented help flags (#97)
Nathanb5f3c45c76d2
diff --git a/book_to_skill/utils.py b/book_to_skill/utils.pyindex 5d3724a..7e106b7 100644--- a/book_to_skill/utils.py+++ b/book_to_skill/utils.py@@ -634,16 +634,32 @@ def print_banner() -> None:pass # best-effort: never block extraction on the banner+def print_usage() -> None:+ """Print standalone CLI usage."""+ print(+ "Usage: book-to-skill <path-to-document-folder-or-glob>... "+ "[--mode technical|text] [--install-missing ask|yes|no]",+ file=sys.stderr,+ )+ print(+ " book-to-skill --check # report which extractors are installed",+ file=sys.stderr,+ )+ print(f"Supported formats: {supported_formats_message()}", file=sys.stderr)++def main():print_banner()+ if any(arg in {"-h", "--help"} for arg in sys.argv[1:]):+ print_usage()+ sys.exit(0)+if "--check" in sys.argv[1:]:sys.exit(run_dependency_check())if len(sys.argv) < 2:- print("Usage: extract.py <path-to-document-folder-or-glob>... [--mode technical|text] [--install-missing ask|yes|no]", file=sys.stderr)- print(" extract.py --check # report which extractors are installed", file=sys.stderr)- print(f"Supported formats: {supported_formats_message()}", file=sys.stderr)+ print_usage()sys.exit(1)raw_input_paths, extraction_mode, install_mode = parse_arguments(sys.argv)diff --git a/tests/test_book_to_skill.py b/tests/test_book_to_skill.pyindex 2d4f3f2..5a1996a 100644--- a/tests/test_book_to_skill.py+++ b/tests/test_book_to_skill.py@@ -1535,6 +1535,38 @@ class TestLowercaseRomanNumerals:assert _chapter_number("## vi. editor") is not None+# ═══════════════════════════════════════════════════════════════════════════+# CLI help entry point+# ═══════════════════════════════════════════════════════════════════════════++class TestCliHelp:+ """The documented help flags should print usage and exit successfully."""++ @pytest.mark.parametrize("flag", ["--help", "-h"])+ def test_help_flag_prints_console_script_usage(self, flag, monkeypatch, capsys):+ monkeypatch.setattr("sys.argv", ["book-to-skill", flag])++ with pytest.raises(SystemExit) as exc_info:+ main()++ captured = capsys.readouterr()+ assert exc_info.value.code == 0+ assert "Usage: book-to-skill" in captured.err+ assert "extract.py" not in captured.err+ assert "Unknown flag" not in captured.err++ def test_no_arguments_keeps_error_exit_with_same_usage(self, monkeypatch, capsys):+ monkeypatch.setattr("sys.argv", ["book-to-skill"])++ with pytest.raises(SystemExit) as exc_info:+ main()++ captured = capsys.readouterr()+ assert exc_info.value.code == 1+ assert "Usage: book-to-skill" in captured.err+ assert "extract.py" not in captured.err++# ═══════════════════════════════════════════════════════════════════════════# Fix #5 — Unknown flag warning in parse_arguments# ═══════════════════════════════════════════════════════════════════════════