fix(chat): remove --cwd from Click options to allow optional value parsing
--cwd was defined as a Click option but also parsed manually from ctx.args, which caused conflicts when --cwd was followed by another flag (like --dangerously-skip-permissions). Now --cwd is parsed entirely manually, allowing: --cwd alone -> use current directory --cwd /path -> use specified path (none) -> use myclaude project root (default)
This commit is contained in:
@@ -79,15 +79,8 @@ def _parse_cwd_from_args(args: list[str]) -> tuple[str | None, list[str]]:
|
||||
default=False,
|
||||
help="Forward to claude: bypass permission checks (sandbox / isolated use only).",
|
||||
)
|
||||
@click.option(
|
||||
"--cwd",
|
||||
"-C",
|
||||
multiple=True,
|
||||
metavar="PATH",
|
||||
help="Working directory for claude (default: myclaude project root; '--cwd' uses current dir; '--cwd /path' uses specific path).",
|
||||
)
|
||||
@click.pass_context
|
||||
def chat_cmd(ctx: click.Context, dangerously_skip_permissions: bool, cwd: tuple[str, ...]) -> None:
|
||||
def chat_cmd(ctx: click.Context, dangerously_skip_permissions: bool) -> None:
|
||||
"""Run `claude` in the myclaude repo so CLAUDE.md and .claude/ apply; extra args pass through.
|
||||
|
||||
\b
|
||||
@@ -104,8 +97,7 @@ def chat_cmd(ctx: click.Context, dangerously_skip_permissions: bool, cwd: tuple[
|
||||
)
|
||||
raise SystemExit(127)
|
||||
|
||||
# Parse --cwd from raw args since Click doesn't support optional values natively
|
||||
# (We ignore the 'cwd' parameter from Click and parse manually from ctx.args)
|
||||
# Parse --cwd from raw args (Click doesn't support optional values natively)
|
||||
cwd_value, remaining_args = _parse_cwd_from_args(ctx.args)
|
||||
|
||||
if cwd_value is None:
|
||||
|
||||
Reference in New Issue
Block a user