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
def detect_strictcli(project_dir: str='.') -> tuple[str, str] | NoneCheck 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
def _detect_python_strictcli(project_dir: str) -> tuple[str, str] | NoneDetect strictcli in a Python project via pyproject.toml.
#_is_strictcli_module_path
def _is_strictcli_module_path(path: str) -> boolReturn 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
def _go_mod_has_strictcli(project_dir: str) -> boolReturn 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
def _go_file_imports_strictcli(filepath: str) -> boolReturn 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
def _go_package_imports_strictcli(project_dir: str, rel_dir: str) -> boolReturn True if any .go file in the package dir imports strictcli.
#_entry_point_path
def _entry_point_path(rel_dir: str) -> strFormat a main-package rel_dir as a go run entry point path.
#_detect_go_strictcli
def _detect_go_strictcli(project_dir: str) -> tuple[str, str] | NoneDetect 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:
- Exactly one main package -> that's the entry point (the strictcli
import may be indirect via an internal package).
- Multiple main packages -> the one whose dir directly imports
strictcli.
- Anything else -> StrictcliDetectError: go.mod requires strictcli,
so failing to find the entry point is a hard error, never a silent 'no strictcli here'.