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

2

3 from __future__ import annotations

4

5 import argparse

6 from typing import TYPE_CHECKING

7

8 if TYPE_CHECKING:

9 from little_loops.config import BRConfig

10

11

12 def positive_int(value: str) -> int:

13 """Argparse type validator that requires a positive integer."""

14 try:

15 n = int(value)

16 except ValueError:

17 raise argparse.ArgumentTypeError(f"{value!r} is not a valid integer") from None

18 if n < 1:

19 raise argparse.ArgumentTypeError(f"--count must be a positive integer, got {n}")

20 return n

21

22

23 def cmd_next_id(config: BRConfig, count: int = 1) -> int:

24 """Print the next globally unique issue number(s).

25

26 Args:

27 config: Project configuration

28 count: Number of consecutive IDs to emit (default 1)

29

30 Returns:

31 Exit code (0 = success)

32 """

33 from little_loops.issue_parser import get_next_issue_number

34

35 base = get_next_issue_number(config)

36 for i in range(count):

37 print(f"{base + i:03d}")

38 return 0