MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / handle_no_command

Function handle_no_command

src/commands.rs:951–990  ·  view source on GitHub ↗

When invoked with no subcommand, offer to create the index if none exists.

()

Source from the content-addressed store, hash-verified

949
950/// When invoked with no subcommand, offer to create the index if none exists.
951pub(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
992pub(crate) async fn handle_init(
993 path: Option<String>,

Callers 1

runFunction · 0.85

Calls 7

resolve_pathFunction · 0.85
is_fresh_installFunction · 0.85
init_and_indexFunction · 0.85
is_terminalMethod · 0.80
flushMethod · 0.45
read_lineMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected