Skip to content

Commit 59944bb

Browse files
jpheinclaude
andcommitted
docs+test+ergonomics(cli): address Copilot review on #1086 export
Three corrections from @copilot-pull-request-reviewer: 1. **Top-of-module docstring updated.** The "Commands" list and "Examples" block now mention `mempalace export -o <dir>` so `mempalace --help` documents the new subcommand consistently with the rest. The epilog is built from this docstring via __doc__, so a stale list is what users actually see. 2. **Per-subcommand --palace dropped.** Other subcommands (mine/search/mcp/status/wake-up) all read args.palace from the global root-parser flag; export's local duplicate broke that consistency. Replaced with a comment explaining the choice. Usage is now `mempalace --palace <p> export -o <d>`. (cmd_export already accesses args.palace, which still resolves correctly via the global parser.) 3. **test_main_export_dispatches added.** Mirrors the test_main_<cmd>_dispatches pattern used for every other subcommand. Asserts the argparse wiring delivers both the global --palace and the -o/--output to cmd_export, and locks in that --output (long form) is also accepted. 45/45 tests pass in tests/test_cli.py. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4790316 commit 59944bb

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

mempalace/cli.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
mempalace mine <dir> --mode convos Mine conversation exports
1717
mempalace mine <dir> --mode extract Mine binary office documents (PDF/DOCX/etc.)
1818
mempalace search "query" Find anything, exact words
19+
mempalace export -o <dir> Export the palace as browsable markdown (one file per room)
1920
mempalace mcp Show MCP setup command
2021
mempalace wake-up Show L0 + L1 wake-up context
2122
mempalace wake-up --wing my_app Wake-up for a specific project
@@ -27,6 +28,7 @@
2728
mempalace mine ~/.claude/projects/-Users-you-Projects-my_app --mode convos --wing my_app
2829
mempalace search "why did we switch to GraphQL"
2930
mempalace search "pricing discussion" --wing my_app --room costs
31+
mempalace export -o ~/Desktop/palace-export
3032
"""
3133

3234
import os
@@ -1784,7 +1786,10 @@ def main():
17841786
p_export.add_argument(
17851787
"-o", "--output", required=True, help="Output directory for markdown files"
17861788
)
1787-
p_export.add_argument("--palace", help="Path to palace directory (default: from config)")
1789+
# No per-subcommand --palace: rely on the root parser's global --palace
1790+
# so usage is `mempalace --palace <path> export -o <dir>` — consistent
1791+
# with mine / search / mcp / status / wake-up which all read args.palace
1792+
# from the global flag.
17881793

17891794
args = parser.parse_args()
17901795
_apply_backend_arg(args)

tests/test_cli.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,36 @@ def test_main_split_dispatches():
823823
mock_cmd.assert_called_once()
824824

825825

826+
def test_main_export_dispatches():
827+
"""Argparse wiring + main() dispatch for the export subcommand.
828+
829+
Locks in -o/--output as the required arg and that the global
830+
--palace flag (root parser) reaches cmd_export via args.palace
831+
— there is no per-subcommand --palace.
832+
"""
833+
from mempalace.cli import cmd_export # noqa: F401 — sanity import
834+
835+
with (
836+
patch("sys.argv", ["mempalace", "--palace", "/tmp/p", "export", "-o", "/tmp/out"]),
837+
patch("mempalace.cli.cmd_export") as mock_cmd,
838+
):
839+
main()
840+
mock_cmd.assert_called_once()
841+
# Forwarded args carry both the global --palace and -o/--output.
842+
forwarded = mock_cmd.call_args[0][0]
843+
assert forwarded.palace == "/tmp/p"
844+
assert forwarded.output == "/tmp/out"
845+
846+
# And the long form -o == --output.
847+
with (
848+
patch("sys.argv", ["mempalace", "export", "--output", "/tmp/out2"]),
849+
patch("mempalace.cli.cmd_export") as mock_cmd,
850+
):
851+
main()
852+
mock_cmd.assert_called_once()
853+
assert mock_cmd.call_args[0][0].output == "/tmp/out2"
854+
855+
826856
def test_mcp_command_prints_setup_guidance(monkeypatch, capsys):
827857
monkeypatch.setattr(sys, "argv", ["mempalace", "mcp"])
828858

0 commit comments

Comments
 (0)