When invoked with no subcommand, offer to create the index if none exists.
()
| 949 | |
| 950 | /// When invoked with no subcommand, offer to create the index if none exists. |
| 951 | pub(crate) async fn handle_no_command() -> tracedecay::errors::Result<()> { |
| 952 | let project_path = tracedecay::config::resolve_path(None); |
| 953 | if TraceDecay::has_initialized_store(&project_path).await { |
| 954 | // Already initialized — show help via clap |
| 955 | let _ = <crate::cli::Cli as clap::CommandFactory>::command().print_help(); |
| 956 | eprintln!(); |
| 957 | return Ok(()); |
| 958 | } |
| 959 | if is_fresh_install().await { |
| 960 | eprintln!("\x1b[1;36mWelcome to tracedecay!\x1b[0m"); |
| 961 | eprintln!( |
| 962 | "Looks like a new installation. To get started, run \x1b[1mtracedecay init\x1b[0m \ |
| 963 | in your project root." |
| 964 | ); |
| 965 | eprintln!(); |
| 966 | } |
| 967 | if !io::stdin().is_terminal() { |
| 968 | eprintln!( |
| 969 | "No TraceDecay index found at '{}'. Non-interactive: skipping index creation (run `tracedecay init`).", |
| 970 | project_path.display() |
| 971 | ); |
| 972 | return Ok(()); |
| 973 | } |
| 974 | eprint!( |
| 975 | "No TraceDecay index found at '{}'. Create one now? [Y/n] ", |
| 976 | project_path.display() |
| 977 | ); |
| 978 | io::stderr().flush().ok(); |
| 979 | let mut answer = String::new(); |
| 980 | io::stdin().lock().read_line(&mut answer).map_err(|e| { |
| 981 | tracedecay::errors::TraceDecayError::Config { |
| 982 | message: format!("failed to read stdin: {}", e), |
| 983 | } |
| 984 | })?; |
| 985 | let answer = answer.trim(); |
| 986 | if answer.is_empty() || answer.eq_ignore_ascii_case("y") { |
| 987 | init_and_index(&project_path, &[], &[], false).await?; |
| 988 | } |
| 989 | Ok(()) |
| 990 | } |
| 991 | |
| 992 | pub(crate) async fn handle_init( |
| 993 | path: Option<String>, |
no test coverage detected