MCPcopy Create free account
hub / github.com/cocoindex-io/cocoindex-code / init

Function init

src/cocoindex_code/cli.py:560–610  ·  view source on GitHub ↗

Initialize a project for cocoindex-code.

(
    litellm_model: str | None = _typer.Option(
        None,
        "--litellm-model",
        help="Use the given LiteLLM model and skip provider/model prompts.",
    ),
    force: bool = _typer.Option(False, "-f", "--force", help="Skip parent directory warning"),
)

Source from the content-addressed store, hash-verified

558
559@app.command()
560def init(
561 litellm_model: str | None = _typer.Option(
562 None,
563 "--litellm-model",
564 help="Use the given LiteLLM model and skip provider/model prompts.",
565 ),
566 force: bool = _typer.Option(False, "-f", "--force", help="Skip parent directory warning"),
567) -> None:
568 """Initialize a project for cocoindex-code."""
569 cwd = Path.cwd().resolve()
570 settings_file = project_settings_path(cwd)
571
572 user_path = user_settings_path()
573 if user_path.is_file():
574 if litellm_model is not None:
575 display_path = format_path_for_display(user_path)
576 _typer.echo(
577 f"Error: global settings already exist at {display_path}.\n"
578 "Edit that file or remove it before passing `--litellm-model`.",
579 err=True,
580 )
581 raise _typer.Exit(code=1)
582 else:
583 _setup_user_settings_interactive(litellm_model)
584
585 # Check if already initialized
586 if settings_file.is_file():
587 _typer.echo("Project already initialized.")
588 return
589
590 # Check parent directories for markers
591 if not force:
592 parent = find_parent_with_marker(cwd)
593 if parent is not None and parent != cwd:
594 display_parent = format_path_for_display(parent)
595 _typer.echo(
596 f"Warning: A parent directory has a project marker: {display_parent}\n"
597 "You might want to run `ccc init` there instead.\n"
598 "Use `ccc init -f` to initialize here anyway."
599 )
600 raise _typer.Exit(code=1)
601
602 # Create project settings
603 save_project_settings(cwd, default_project_settings())
604 _typer.echo(f"Created project settings: {format_path_for_display(settings_file)}")
605
606 # Add to .gitignore
607 add_to_gitignore(cwd)
608
609 _typer.echo("You can edit the settings files to customize indexing behavior.")
610 _typer.echo("Run `ccc index` to build the index.")
611
612
613@app.command()

Callers

nothing calls this directly

Calls 8

project_settings_pathFunction · 0.85
user_settings_pathFunction · 0.85
format_path_for_displayFunction · 0.85
find_parent_with_markerFunction · 0.85
save_project_settingsFunction · 0.85
default_project_settingsFunction · 0.85
add_to_gitignoreFunction · 0.85

Tested by

no test coverage detected