Main entry point for the cgc CLI application. If no subcommand is provided, it displays a welcome message with instructions.
(
ctx: typer.Context,
database: Optional[str] = typer.Option(
None,
"--database",
"--db",
"-db",
help="[Global] Temporarily override database backend ("
+ "|".join(config_manager.SUPPORTED_DATABASES)
+ ") for any command"
),
visual: bool = typer.Option(
False,
"--visual",
"--viz",
"-V",
help="[Global] Show results as interactive graph visualization in browser"
),
version_: bool = typer.Option(
None,
"--version",
"-v",
help="[Root-level only] Show version and exit",
is_eager=True,
),
help_: bool = typer.Option(
None,
"--help",
"-h",
help="[Root-level only] Show help and exit",
is_eager=True,
),
db_path: Optional[str] = typer.Option(
None,
"--path",
"--db-path",
help="[Global] Temporarily override database path (for local DBs like KuzuDB)"
),
)
| 3138 | |
| 3139 | @app.callback(invoke_without_command=True) |
| 3140 | def main( |
| 3141 | ctx: typer.Context, |
| 3142 | database: Optional[str] = typer.Option( |
| 3143 | None, |
| 3144 | "--database", |
| 3145 | "--db", |
| 3146 | "-db", |
| 3147 | help="[Global] Temporarily override database backend (" |
| 3148 | + "|".join(config_manager.SUPPORTED_DATABASES) |
| 3149 | + ") for any command" |
| 3150 | ), |
| 3151 | visual: bool = typer.Option( |
| 3152 | False, |
| 3153 | "--visual", |
| 3154 | "--viz", |
| 3155 | "-V", |
| 3156 | help="[Global] Show results as interactive graph visualization in browser" |
| 3157 | ), |
| 3158 | version_: bool = typer.Option( |
| 3159 | None, |
| 3160 | "--version", |
| 3161 | "-v", |
| 3162 | help="[Root-level only] Show version and exit", |
| 3163 | is_eager=True, |
| 3164 | ), |
| 3165 | help_: bool = typer.Option( |
| 3166 | None, |
| 3167 | "--help", |
| 3168 | "-h", |
| 3169 | help="[Root-level only] Show help and exit", |
| 3170 | is_eager=True, |
| 3171 | ), |
| 3172 | db_path: Optional[str] = typer.Option( |
| 3173 | None, |
| 3174 | "--path", |
| 3175 | "--db-path", |
| 3176 | help="[Global] Temporarily override database path (for local DBs like KuzuDB)" |
| 3177 | ), |
| 3178 | ): |
| 3179 | """ |
| 3180 | Main entry point for the cgc CLI application. |
| 3181 | If no subcommand is provided, it displays a welcome message with instructions. |
| 3182 | """ |
| 3183 | if db_path: |
| 3184 | os.environ["CGC_RUNTIME_DB_PATH"] = db_path |
| 3185 | if database: |
| 3186 | os.environ["CGC_RUNTIME_DB_TYPE"] = database |
| 3187 | # Initialize context object for sharing state with subcommands |
| 3188 | ctx.ensure_object(dict) |
| 3189 | |
| 3190 | # Store visual flag in context for subcommands to access |
| 3191 | if visual: |
| 3192 | ctx.obj["visual"] = True |
| 3193 | |
| 3194 | if version_: |
| 3195 | console.print(f"CodeGraphContext [bold cyan]{get_version()}[/bold cyan]") |
| 3196 | raise typer.Exit() |
| 3197 |
nothing calls this directly
no test coverage detected