Add script detection, env shebang parser, and opt-in content guessing

This commit is contained in:
2026-04-03 13:55:54 -07:00
parent 63102473da
commit 37502c3083
8 changed files with 337 additions and 7 deletions

View File

@@ -65,6 +65,13 @@ def main(
help="Use pager for output. Default: auto-detect.",
),
] = None,
guess_content: Annotated[
bool,
typer.Option(
"--guess-content/--no-guess-content",
help="Use heuristic content-based type detection as a fallback.",
),
] = False,
version: Annotated[
bool | None,
typer.Option(
@@ -84,6 +91,7 @@ def main(
theme: Pygments color theme.
line_numbers: Show line numbers. Default: auto.
pager: Use pager for output. Default: auto-detect.
guess_content: Use heuristic content-based type detection as a fallback.
version: Show version and exit.
"""
console = Console()
@@ -114,7 +122,12 @@ def main(
console.print("[dim]Empty input, nothing to display.[/dim]")
raise typer.Exit()
file_type = detect_type(path=file_path, content=content, explicit_type=file_type)
file_type = detect_type(
path=file_path,
content=content,
explicit_type=file_type,
guess_content=guess_content,
)
options = RenderOptions(
theme=theme,