Coverage for little_loops / cli / issues / path_cmd.py: 89%

19 statements  

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

1"""ll-issues path: Print the file path for an issue ID.""" 

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 

14def cmd_path(config: BRConfig, args: argparse.Namespace) -> int: 

15 """Print relative path to an issue file. 

16 

17 Args: 

18 config: Project configuration 

19 args: Parsed arguments with .issue_id (str) and optional .json (bool) 

20 

21 Returns: 

22 0 if found, 1 if not found 

23 """ 

24 from little_loops.cli.issues.show import _resolve_issue_id 

25 from little_loops.cli.output import print_json 

26 

27 path = _resolve_issue_id(config, args.issue_id) 

28 if path is None: 

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

30 return 1 

31 

32 try: 

33 rel_path = str(path.relative_to(config.project_root)) 

34 except ValueError: 

35 rel_path = str(path) 

36 

37 if getattr(args, "json", False): 

38 print_json({"path": rel_path}) 

39 return 0 

40 

41 print(rel_path) 

42 return 0