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)"
),
)
| 2939 | |
| 2940 | @app.callback(invoke_without_command=True) |
| 2941 | def main( |
| 2942 | ctx: typer.Context, |
| 2943 | database: Optional[str] = typer.Option( |
| 2944 | None, |
| 2945 | "--database", |
| 2946 | "--db", |
| 2947 | "-db", |
| 2948 | help="[Global] Temporarily override database backend (" |
| 2949 | + "|".join(config_manager.SUPPORTED_DATABASES) |
| 2950 | + ") for any command" |
| 2951 | ), |
| 2952 | visual: bool = typer.Option( |
| 2953 | False, |
| 2954 | "--visual", |
| 2955 | "--viz", |
| 2956 | "-V", |
| 2957 | help="[Global] Show results as interactive graph visualization in browser" |
| 2958 | ), |
| 2959 | version_: bool = typer.Option( |
| 2960 | None, |
| 2961 | "--version", |
| 2962 | "-v", |
| 2963 | help="[Root-level only] Show version and exit", |
| 2964 | is_eager=True, |
| 2965 | ), |
| 2966 | help_: bool = typer.Option( |
| 2967 | None, |
| 2968 | "--help", |
| 2969 | "-h", |
| 2970 | help="[Root-level only] Show help and exit", |
| 2971 | is_eager=True, |
| 2972 | ), |
| 2973 | db_path: Optional[str] = typer.Option( |
| 2974 | None, |
| 2975 | "--path", |
| 2976 | "--db-path", |
| 2977 | help="[Global] Temporarily override database path (for local DBs like KuzuDB)" |
| 2978 | ), |
| 2979 | ): |
| 2980 | """ |
| 2981 | Main entry point for the cgc CLI application. |
| 2982 | If no subcommand is provided, it displays a welcome message with instructions. |
| 2983 | """ |
| 2984 | if db_path: |
| 2985 | os.environ["CGC_RUNTIME_DB_PATH"] = db_path |
| 2986 | if database: |
| 2987 | os.environ["CGC_RUNTIME_DB_TYPE"] = database |
| 2988 | # Initialize context object for sharing state with subcommands |
| 2989 | ctx.ensure_object(dict) |
| 2990 | |
| 2991 | # Store visual flag in context for subcommands to access |
| 2992 | if visual: |
| 2993 | ctx.obj["visual"] = True |
| 2994 | |
| 2995 | if version_: |
| 2996 | console.print(f"CodeGraphContext [bold cyan]{get_version()}[/bold cyan]") |
| 2997 | raise typer.Exit() |
| 2998 |
nothing calls this directly
no test coverage detected