Coverage for little_loops/cli/next_id.py: 100%

1"""ll-next-id: Print the next globally unique issue number."""

2

3 from __future__ import annotations

4

5 import argparse

6 from pathlib import Path

7

8

9 def main_next_id() -> int:

10 """Entry point for ll-next-id command.

11

12 Prints the next globally unique issue number by scanning all issue

13 directories (active and completed). Wraps get_next_issue_number().

14

15 Returns:

16 Exit code (0 = success)

17 """

18 from little_loops.config import BRConfig

19 from little_loops.issue_parser import get_next_issue_number

20

21 parser = argparse.ArgumentParser(

22 prog="ll-next-id",

23 description="Print the next globally unique issue number",

24 formatter_class=argparse.RawDescriptionHelpFormatter,

25 epilog="""

26 Examples:

27 %(prog)s # Print next issue number (e.g., 042)

28 %(prog)s --config /path # Use specific project root

29""",

30 )

31

32 parser.add_argument(

33 "--config",

34 type=Path,

35 default=None,

36 help="Path to project root (default: current directory)",

37 )

38

39 args = parser.parse_args()

40

41 project_root = args.config or Path.cwd()

42 config = BRConfig(project_root)

43

44 next_num = get_next_issue_number(config)

45 print(f"{next_num:03d}")

46

47 return 0