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

Function require_project_root

src/cocoindex_code/cli.py:79–101  ·  view source on GitHub ↗

Find the project root by walking up from CWD. Checks global settings first (more fundamental), then project settings. Exits with code 1 if either check fails.

()

Source from the content-addressed store, hash-verified

77
78
79def require_project_root() -> Path:
80 """Find the project root by walking up from CWD.
81
82 Checks global settings first (more fundamental), then project settings.
83 Exits with code 1 if either check fails.
84 """
85 gs_path = user_settings_path()
86 if not gs_path.is_file():
87 _typer.echo(
88 f"Error: Global settings not found: {format_path_for_display(gs_path)}\n"
89 "Run `ccc init` to create it with default settings.",
90 err=True,
91 )
92 raise _typer.Exit(code=1)
93 root = find_project_root(Path.cwd())
94 if root is None:
95 _typer.echo(
96 "Error: Not in an initialized project directory.\n"
97 "Run `ccc init` in your project root to get started.",
98 err=True,
99 )
100 raise _typer.Exit(code=1)
101 return root
102
103
104_F = TypeVar("_F", bound=Callable[..., object])

Callers 7

indexFunction · 0.85
searchFunction · 0.85
statusFunction · 0.85
resetFunction · 0.85
mcpFunction · 0.85

Calls 3

user_settings_pathFunction · 0.85
format_path_for_displayFunction · 0.85
find_project_rootFunction · 0.85