lean_ctx_cli/cli/
claude_mod_cmd.rs1use lean_ctx_hooks::hooks::agents::claude_mod::{self, ModStatus};
6
7const USAGE: &str = "\
8lean-ctx claude-mod — the lean-ctx mod for Claude Code (2.1.287+)
9
10USAGE:
11 lean-ctx claude-mod [status] Show whether the mod is installed and current
12 lean-ctx claude-mod install Install, or refresh to this instance's version
13 lean-ctx claude-mod uninstall Remove the mod and its local marketplace
14
15The mod wakes the model when ctx_shell background jobs finish (no sleep/status
16polling), keeps lean-ctx's core tools in front of ToolSearch, and adds /leanctx
17with the session's real request and token usage. It runs inside Claude Code with
18your permissions; its source ships in this binary and is installed from a local
19marketplace — nothing is downloaded.";
20
21pub fn cmd_claude_mod(args: &[String]) {
22 match args.first().map(String::as_str) {
23 Some("-h" | "--help" | "help") => println!("{USAGE}"),
24 None | Some("status") => {
25 let status = claude_mod::status();
26 println!("{}: {}", claude_mod::PLUGIN_ID, status.describe());
27 match status {
28 ModStatus::NotInstalled => println!(" install: lean-ctx claude-mod install"),
29 ModStatus::Stale(_) => println!(" refresh: lean-ctx claude-mod install"),
30 _ => {}
31 }
32 }
33 Some("install" | "update") => report(claude_mod::install()),
34 Some("uninstall" | "remove") => report(claude_mod::uninstall()),
35 Some(other) => {
36 eprintln!("unknown claude-mod action: {other}\n\n{USAGE}");
37 std::process::exit(2);
38 }
39 }
40}
41
42fn report(result: Result<String, String>) {
43 match result {
44 Ok(msg) => println!("{msg}"),
45 Err(e) => {
46 eprintln!("lean-ctx claude-mod: {e}");
47 std::process::exit(1);
48 }
49 }
50}