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