rlsbl v0.113.0 /rlsbl.strictcli_detect
On this page

Detect whether a Python project uses strictcli by scanning pyproject.toml dependencies and extract its script entry point for schema dumping.

#rlsbl.strictcli_detect

#rlsbl.strictcli_detect

Detect whether a project uses strictcli and extract its entry point.

#StrictcliDetectError

The project requires strictcli but its entry point cannot be determined -- callers must treat this as a hard error, never as 'project does not use strictcli'.

#detect_strictcli

python
def detect_strictcli(project_dir: str='.') -> tuple[str, str] | None

Check if a project uses strictcli and return its entry point info.

First checks Python (pyproject.toml). If not found, checks Go (go.mod).

For Python: if the project depends on strictcli and has a [project.scripts] entry, returns (entry_point_name, "python").

For Go: if go.mod requires github.com/smm-h/strictcli, enumerates main packages via the go toolchain (go_introspect) and returns (package_path, "go") -- see _detect_go_strictcli for the resolution rules (single main, or the one main whose dir imports strictcli).

Args:

  • project_dir: path to the project root (default: current directory).

Returns:

  • A tuple (entry_point, language) if strictcli is detected, else None.

#_detect_python_strictcli

python
def _detect_python_strictcli(project_dir: str) -> tuple[str, str] | None

Detect strictcli in a Python project via pyproject.toml.

#_is_strictcli_module_path

python
def _is_strictcli_module_path(path: str) -> bool

Return True if a Go module path is strictcli or a sub-path of it (e.g. github.com/smm-h/strictcli/go), not a mere string prefix (e.g. github.com/smm-h/strictcli-extras).

#_go_mod_has_strictcli

python
def _go_mod_has_strictcli(project_dir: str) -> bool

Return True if go.mod has a require directive for a strictcli module.

Only require directives count -- both the single-line form (require path version) and the block form (require ( ... )). The module declaration is never a match: the strictcli library's own go.mod declares module github.com/smm-h/strictcli/go, and treating that as a dependency made rlsbl demand a strictcli entry point from the strictcli library itself.

#_go_file_imports_strictcli

python
def _go_file_imports_strictcli(filepath: str) -> bool

Return True if a Go source file imports a strictcli package.

Uses tree-sitter via lint/go_ast.scan_imports for accurate parsing.

#_go_package_imports_strictcli

python
def _go_package_imports_strictcli(project_dir: str, rel_dir: str) -> bool

Return True if any .go file in the package dir imports strictcli.

#_entry_point_path

python
def _entry_point_path(rel_dir: str) -> str

Format a main-package rel_dir as a go run entry point path.

#_detect_go_strictcli

python
def _detect_go_strictcli(project_dir: str) -> tuple[str, str] | None

Detect strictcli in a Go project via go.mod and go list.

Main packages are enumerated with the go toolchain (go_introspect), which handles entry files not named main.go, _test.go files in package main, and broken-root layouts.

Resolution:

  1. Exactly one main package -> that's the entry point (the strictcli

import may be indirect via an internal package).

  1. Multiple main packages -> the one whose dir directly imports

strictcli.

  1. Anything else -> StrictcliDetectError: go.mod requires strictcli,

so failing to find the entry point is a hard error, never a silent 'no strictcli here'.

Search