Coverage for little_loops / cli / issues / check_flag.py: 36%

14 statements  

« prev     ^ index     » next       coverage.py v7.12.0, created at 2026-05-22 16:19 -0500

1"""ll-issues check-flag: Exit 0 if a boolean frontmatter field equals 'true'.""" 

2 

3from __future__ import annotations 

4 

5import argparse 

6import sys 

7from typing import TYPE_CHECKING 

8 

9if TYPE_CHECKING: 

10 from little_loops.config import BRConfig 

11 

12 

13def cmd_check_flag(config: BRConfig, args: argparse.Namespace) -> int: 

14 """Exit 0 if the named frontmatter field on the issue equals 'true'. 

15 

16 Args: 

17 config: Project configuration 

18 args: Parsed arguments with .issue_id and .field 

19 

20 Returns: 

21 0 if the field is 'true', 1 otherwise 

22 """ 

23 from little_loops.cli.issues.show import _resolve_issue_id 

24 from little_loops.frontmatter import parse_frontmatter 

25 

26 path = _resolve_issue_id(config, args.issue_id) 

27 if path is None: 

28 print(f"Error: Issue '{args.issue_id}' not found.", file=sys.stderr) 

29 return 1 

30 

31 fm = parse_frontmatter(path.read_text(), coerce_types=True) 

32 value = fm.get(args.field) 

33 return 0 if str(value).lower() == "true" else 1