mirror of
https://github.com/instructkr/claude-code.git
synced 2026-06-05 12:06:43 +00:00
fix: reject --compact for non-prompt subcommands (#98)
--compact was silently ignored when used with non-prompt commands like claw --compact status or claw --compact config. Now returns a typed error with guidance on proper usage. Generated with https://github.com/Yeachan-Heo/gajae-code Co-authored-by: Gajae Code <dev@gajae-code.com>
This commit is contained in:
@@ -1919,6 +1919,25 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
|
||||
.unwrap_or_else(permission_mode_provenance_for_current_dir)
|
||||
};
|
||||
|
||||
// #98: --compact is only meaningful for prompt mode. When a known non-prompt
|
||||
// subcommand is being dispatched, reject --compact so callers don't silently
|
||||
// lose the flag.
|
||||
if compact
|
||||
&& rest
|
||||
.first()
|
||||
.map(|s| s.as_str())
|
||||
.is_some_and(|s| s != "prompt")
|
||||
{
|
||||
// Allow compact for the default prompt fallback (unknown tokens).
|
||||
// Only reject for known top-level subcommands that don't use compact.
|
||||
let first = rest[0].as_str();
|
||||
if is_known_top_level_subcommand(first) && first != "prompt" {
|
||||
return Err(format!(
|
||||
"invalid_flag_value: --compact is only supported with prompt mode.\nUsage: claw --compact \"<prompt>\" or echo \"<prompt>\" | claw --compact"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
match rest[0].as_str() {
|
||||
"dump-manifests" => parse_dump_manifests_args(&rest[1..], output_format),
|
||||
"bootstrap-plan" => Ok(CliAction::BootstrapPlan { output_format }),
|
||||
|
||||
Reference in New Issue
Block a user