Skip to content

Index Cmd

CLI command for indexing repositories.

logger module-attribute

logger = getLogger(__name__)

PathArg module-attribute

PathArg = Annotated[
	Path,
	Argument(
		help="Path to the repository root directory.",
		exists=True,
		file_okay=False,
		dir_okay=True,
		readable=True,
		resolve_path=True,
	),
]

SyncOpt module-attribute

SyncOpt = Annotated[
	bool,
	Option(
		"--sync/--no-sync",
		help="Synchronize the vector database with the current Git state on startup.",
	),
]

WatchOpt module-attribute

WatchOpt = Annotated[
	bool,
	Option(
		"--watch",
		"-w",
		help="Keep running and watch for file changes, automatically syncing the index.",
	),
]

register_command

register_command(app: Typer) -> None

Register the index command with the CLI app.

Source code in src/codemap/cli/index_cmd.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
def register_command(app: typer.Typer) -> None:
	"""Register the index command with the CLI app."""

	@app.command(name="index")
	def index_command(
		path: PathArg = Path(),
		sync: SyncOpt = True,
		watch: WatchOpt = False,
	) -> None:
		"""
		Index the repository: Process files, generate embeddings, and store in the vector database.

		Optionally, use --sync (default) to synchronize with the Git state on startup,
		and --watch (-w) to keep running and sync automatically on file changes.
		"""
		# Defer heavy imports and logic to the implementation function
		_index_command_impl(
			path=path,
			sync=sync,
			watch=watch,
		)