mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-27 05:34:57 +08:00
Compare commits
2 Commits
feat/jobdo
...
feat/jobdo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
860f285f70 | ||
|
|
9dd7e79eb2 |
@@ -739,6 +739,9 @@ enum LocalHelpTopic {
|
|||||||
Meta,
|
Meta,
|
||||||
Submit,
|
Submit,
|
||||||
Resume,
|
Resume,
|
||||||
|
// #130e-B: help parity — surface-level bugs (plugins, prompt)
|
||||||
|
Plugins,
|
||||||
|
Prompt,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
@@ -787,20 +790,20 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
|
|||||||
if !rest.is_empty()
|
if !rest.is_empty()
|
||||||
&& matches!(
|
&& matches!(
|
||||||
rest[0].as_str(),
|
rest[0].as_str(),
|
||||||
"prompt"
|
"commit"
|
||||||
| "commit"
|
|
||||||
| "pr"
|
| "pr"
|
||||||
| "issue"
|
| "issue"
|
||||||
) =>
|
) =>
|
||||||
{
|
{
|
||||||
// `--help` following a subcommand that would otherwise forward
|
// `--help` following a subcommand that would otherwise forward
|
||||||
// the arg to the API (e.g. `claw prompt --help`) should show
|
// the arg to the API should show top-level help instead.
|
||||||
// top-level help instead. Subcommands that consume their own
|
// Subcommands that consume their own args (agents, mcp, plugins,
|
||||||
// args (agents, mcp, plugins, skills) and local help-topic
|
// skills) and local help-topic subcommands (status, sandbox,
|
||||||
// subcommands (status, sandbox, doctor, init, state, export,
|
// doctor, init, state, export, version, system-prompt,
|
||||||
// version, system-prompt, dump-manifests, bootstrap-plan) must
|
// dump-manifests, bootstrap-plan, diff, config, help, submit,
|
||||||
// NOT be intercepted here — they handle --help in their own
|
// resume, prompt) must NOT be intercepted here — they handle
|
||||||
// dispatch paths via parse_local_help_action(). See #141.
|
// --help in their own dispatch paths via
|
||||||
|
// parse_local_help_action(). See #141, #130c, #130d, #130e.
|
||||||
wants_help = true;
|
wants_help = true;
|
||||||
index += 1;
|
index += 1;
|
||||||
}
|
}
|
||||||
@@ -1185,7 +1188,16 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
|
|||||||
"system-prompt" => parse_system_prompt_args(&rest[1..], output_format),
|
"system-prompt" => parse_system_prompt_args(&rest[1..], output_format),
|
||||||
"acp" => parse_acp_args(&rest[1..], output_format),
|
"acp" => parse_acp_args(&rest[1..], output_format),
|
||||||
"login" | "logout" => Err(removed_auth_surface_error(rest[0].as_str())),
|
"login" | "logout" => Err(removed_auth_surface_error(rest[0].as_str())),
|
||||||
"init" => Ok(CliAction::Init { output_format }),
|
"init" => {
|
||||||
|
// #152: init is a no-arg verb. Reject unexpected suffixes like `claw init foo`.
|
||||||
|
if rest.len() > 1 {
|
||||||
|
return Err(format!(
|
||||||
|
"unrecognized argument `{}` for subcommand `init`",
|
||||||
|
rest[1]
|
||||||
|
));
|
||||||
|
}
|
||||||
|
Ok(CliAction::Init { output_format })
|
||||||
|
}
|
||||||
"export" => parse_export_args(&rest[1..], output_format),
|
"export" => parse_export_args(&rest[1..], output_format),
|
||||||
"prompt" => {
|
"prompt" => {
|
||||||
let prompt = rest[1..].join(" ");
|
let prompt = rest[1..].join(" ");
|
||||||
@@ -1286,6 +1298,9 @@ fn parse_local_help_action(rest: &[String]) -> Option<Result<CliAction, String>>
|
|||||||
"help" => LocalHelpTopic::Meta,
|
"help" => LocalHelpTopic::Meta,
|
||||||
"submit" => LocalHelpTopic::Submit,
|
"submit" => LocalHelpTopic::Submit,
|
||||||
"resume" => LocalHelpTopic::Resume,
|
"resume" => LocalHelpTopic::Resume,
|
||||||
|
// #130e-B: help parity — surface fixes
|
||||||
|
"plugins" => LocalHelpTopic::Plugins,
|
||||||
|
"prompt" => LocalHelpTopic::Prompt,
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
Some(Ok(CliAction::HelpTopic(topic)))
|
Some(Ok(CliAction::HelpTopic(topic)))
|
||||||
@@ -6151,6 +6166,23 @@ fn render_help_topic(topic: LocalHelpTopic) -> String {
|
|||||||
Requires valid Anthropic credentials (ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY)
|
Requires valid Anthropic credentials (ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY)
|
||||||
Related claw submit · claw --resume · /session list"
|
Related claw submit · claw --resume · /session list"
|
||||||
.to_string(),
|
.to_string(),
|
||||||
|
// #130e-B: help topic for `claw plugins --help`.
|
||||||
|
LocalHelpTopic::Plugins => "Plugins
|
||||||
|
Usage claw plugins [list|install|enable|disable|uninstall|update] [<target>]
|
||||||
|
Purpose manage bundled and user plugins from the CLI surface
|
||||||
|
Defaults list (no action prints inventory)
|
||||||
|
Sources .claw/plugins.json, bundled catalog, user-installed
|
||||||
|
Formats text (default), json
|
||||||
|
Related claw mcp · claw skills · /plugins (REPL)"
|
||||||
|
.to_string(),
|
||||||
|
// #130e-B: help topic for `claw prompt --help`.
|
||||||
|
LocalHelpTopic::Prompt => "Prompt
|
||||||
|
Usage claw prompt <prompt-text>
|
||||||
|
Purpose run a single-turn, non-interactive prompt and exit (like --print mode)
|
||||||
|
Flags --model · --allowedTools · --output-format · --compact
|
||||||
|
Requires valid Anthropic credentials (ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY)
|
||||||
|
Related claw submit · claw (bare, interactive REPL)"
|
||||||
|
.to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10540,6 +10572,43 @@ mod tests {
|
|||||||
let resume_h = parse_args(&["resume".to_string(), "-h".to_string()])
|
let resume_h = parse_args(&["resume".to_string(), "-h".to_string()])
|
||||||
.expect("resume -h must parse");
|
.expect("resume -h must parse");
|
||||||
assert!(matches!(resume_h, CliAction::HelpTopic(LocalHelpTopic::Resume)));
|
assert!(matches!(resume_h, CliAction::HelpTopic(LocalHelpTopic::Resume)));
|
||||||
|
// #130e-B: surface-level help fixes for plugins and prompt.
|
||||||
|
// These previously emitted "Unknown action" (plugins) or wrong help (prompt).
|
||||||
|
let plugins_help = parse_args(&[
|
||||||
|
"plugins".to_string(),
|
||||||
|
"--help".to_string(),
|
||||||
|
])
|
||||||
|
.expect("plugins --help must parse as help action");
|
||||||
|
assert!(
|
||||||
|
matches!(plugins_help, CliAction::HelpTopic(LocalHelpTopic::Plugins)),
|
||||||
|
"#130e-B: plugins --help must route to LocalHelpTopic::Plugins, got: {plugins_help:?}"
|
||||||
|
);
|
||||||
|
let prompt_help = parse_args(&[
|
||||||
|
"prompt".to_string(),
|
||||||
|
"--help".to_string(),
|
||||||
|
])
|
||||||
|
.expect("prompt --help must parse as help action");
|
||||||
|
assert!(
|
||||||
|
matches!(prompt_help, CliAction::HelpTopic(LocalHelpTopic::Prompt)),
|
||||||
|
"#130e-B: prompt --help must route to LocalHelpTopic::Prompt, got: {prompt_help:?}"
|
||||||
|
);
|
||||||
|
// Short forms
|
||||||
|
let plugins_h = parse_args(&["plugins".to_string(), "-h".to_string()])
|
||||||
|
.expect("plugins -h must parse");
|
||||||
|
assert!(matches!(plugins_h, CliAction::HelpTopic(LocalHelpTopic::Plugins)));
|
||||||
|
let prompt_h = parse_args(&["prompt".to_string(), "-h".to_string()])
|
||||||
|
.expect("prompt -h must parse");
|
||||||
|
assert!(matches!(prompt_h, CliAction::HelpTopic(LocalHelpTopic::Prompt)));
|
||||||
|
// Non-regression: `prompt "actual text"` still parses as Prompt action
|
||||||
|
let prompt_action = parse_args(&[
|
||||||
|
"prompt".to_string(),
|
||||||
|
"hello world".to_string(),
|
||||||
|
])
|
||||||
|
.expect("prompt with real text must parse");
|
||||||
|
assert!(
|
||||||
|
matches!(prompt_action, CliAction::Prompt { ref prompt, .. } if prompt == "hello world"),
|
||||||
|
"#130e-B: prompt with real text must route to Prompt action"
|
||||||
|
);
|
||||||
// #147: empty / whitespace-only positional args must be rejected
|
// #147: empty / whitespace-only positional args must be rejected
|
||||||
// with a specific error instead of falling through to the prompt
|
// with a specific error instead of falling through to the prompt
|
||||||
// path (where they surface a misleading "missing Anthropic
|
// path (where they surface a misleading "missing Anthropic
|
||||||
|
|||||||
Reference in New Issue
Block a user