Skip to content

Commit 1e2f68c

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 fc80fef commit 1e2f68c

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
@@ -14,6 +14,7 @@
1414
mempalace mine <dir> Mine project files (default)
1515
mempalace mine <dir> --mode convos Mine conversation exports
1616
mempalace search "query" Find anything, exact words
17+
mempalace export -o <dir> Export the palace as browsable markdown (one file per room)
1718
mempalace mcp Show MCP setup command
1819
mempalace wake-up Show L0 + L1 wake-up context
1920
mempalace wake-up --wing my_app Wake-up for a specific project
@@ -25,6 +26,7 @@
2526
mempalace mine ~/.claude/projects/-Users-you-Projects-my_app --mode convos --wing my_app
2627
mempalace search "why did we switch to GraphQL"
2728
mempalace search "pricing discussion" --wing my_app --room costs
29+
mempalace export -o ~/Desktop/palace-export
2830
"""
2931

3032
import os
@@ -1522,7 +1524,10 @@ def main():
15221524
p_export.add_argument(
15231525
"-o", "--output", required=True, help="Output directory for markdown files"
15241526
)
1525-
p_export.add_argument("--palace", help="Path to palace directory (default: from config)")
1527+
# No per-subcommand --palace: rely on the root parser's global --palace
1528+
# so usage is `mempalace --palace <path> export -o <dir>` — consistent
1529+
# with mine / search / mcp / status / wake-up which all read args.palace
1530+
# from the global flag.
15261531

15271532
args = parser.parse_args()
15281533

tests/test_cli.py

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

726726

727+
def test_main_export_dispatches():
728+
"""Argparse wiring + main() dispatch for the export subcommand.
729+
730+
Locks in -o/--output as the required arg and that the global
731+
--palace flag (root parser) reaches cmd_export via args.palace
732+
— there is no per-subcommand --palace.
733+
"""
734+
from mempalace.cli import cmd_export # noqa: F401 — sanity import
735+
736+
with (
737+
patch("sys.argv", ["mempalace", "--palace", "/tmp/p", "export", "-o", "/tmp/out"]),
738+
patch("mempalace.cli.cmd_export") as mock_cmd,
739+
):
740+
main()
741+
mock_cmd.assert_called_once()
742+
# Forwarded args carry both the global --palace and -o/--output.
743+
forwarded = mock_cmd.call_args[0][0]
744+
assert forwarded.palace == "/tmp/p"
745+
assert forwarded.output == "/tmp/out"
746+
747+
# And the long form -o == --output.
748+
with (
749+
patch("sys.argv", ["mempalace", "export", "--output", "/tmp/out2"]),
750+
patch("mempalace.cli.cmd_export") as mock_cmd,
751+
):
752+
main()
753+
mock_cmd.assert_called_once()
754+
assert mock_cmd.call_args[0][0].output == "/tmp/out2"
755+
756+
727757
def test_mcp_command_prints_setup_guidance(monkeypatch, capsys):
728758
monkeypatch.setattr(sys, "argv", ["mempalace", "mcp"])
729759

0 commit comments

Comments
 (0)