Coverage for little_loops / cli / issues / sections.py: 0%

20 statements  

« prev     ^ index     » next       coverage.py v7.12.0, created at 2026-06-29 00:54 -0500

1"""ll-issues sections: Print section template JSON for an issue type.""" 

2 

3from __future__ import annotations 

4 

5import sys 

6from typing import TYPE_CHECKING 

7 

8if TYPE_CHECKING: 

9 import argparse 

10 

11 from little_loops.config import BRConfig 

12 

13_VALID_TYPES = ("bug", "feat", "enh", "epic") 

14 

15 

16def cmd_sections(config: BRConfig, args: argparse.Namespace) -> int: 

17 """Print section template JSON (or its path) for an issue type. 

18 

19 Args: 

20 config: Project configuration 

21 args: Parsed arguments with .type (str) and optional .path (bool) 

22 

23 Returns: 

24 0 on success, 1 on invalid type or missing template 

25 """ 

26 from little_loops.issue_template import resolve_templates_dir 

27 

28 issue_type = args.type.lower() 

29 if issue_type not in _VALID_TYPES: 

30 print( 

31 f"Error: invalid type '{args.type}' — must be bug, feat, enh, or epic", 

32 file=sys.stderr, 

33 ) 

34 return 1 

35 

36 templates_dir = resolve_templates_dir(config) 

37 json_path = templates_dir / f"{issue_type}-sections.json" 

38 

39 if not json_path.exists(): 

40 print(f"Error: template not found: {json_path}", file=sys.stderr) 

41 return 1 

42 

43 if getattr(args, "path", False): 

44 print(json_path) 

45 return 0 

46 

47 print(json_path.read_text()) 

48 return 0