Coverage for src/prosemark/templates/ports/user_prompter_port.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-09-30 23:09 +0000

1"""User Prompter Port Contract. 

2 

3Defines the interface for user interaction during template instantiation. 

4""" 

5 

6from abc import ABC, abstractmethod 

7 

8from prosemark.templates.domain.entities.placeholder import Placeholder, PlaceholderValue 

9 

10 

11class UserPrompterPort(ABC): 

12 """Port for user interaction during template instantiation.""" 

13 

14 @abstractmethod 

15 def prompt_for_placeholder_values(self, placeholders: list[Placeholder]) -> dict[str, PlaceholderValue]: 

16 """Prompt user for values for all placeholders. 

17 

18 Args: 

19 placeholders: List of placeholders requiring values 

20 

21 Returns: 

22 Dictionary mapping placeholder names to their values 

23 

24 Raises: 

25 UserCancelledError: If user cancels the operation 

26 InvalidPlaceholderValueError: If user provides invalid value 

27 

28 """ 

29 

30 @abstractmethod 

31 def prompt_for_single_value(self, placeholder: Placeholder) -> PlaceholderValue: 

32 """Prompt user for a single placeholder value. 

33 

34 Args: 

35 placeholder: Placeholder requiring a value 

36 

37 Returns: 

38 PlaceholderValue with user input 

39 

40 Raises: 

41 UserCancelledError: If user cancels the operation 

42 InvalidPlaceholderValueError: If user provides invalid value 

43 

44 """ 

45 

46 @abstractmethod 

47 def confirm_template_selection(self, template_name: str) -> bool: 

48 """Confirm with user that they want to use the selected template. 

49 

50 Args: 

51 template_name: Name of template to confirm 

52 

53 Returns: 

54 True if user confirms, False otherwise 

55 

56 """ 

57 

58 @abstractmethod 

59 def display_template_list(self, templates: list[str]) -> None: 

60 """Display list of available templates to user. 

61 

62 Args: 

63 templates: List of template names to display 

64 

65 """ 

66 

67 @abstractmethod 

68 def show_error_message(self, message: str) -> None: 

69 """Display error message to user. 

70 

71 Args: 

72 message: Error message to display 

73 

74 """ 

75 

76 @abstractmethod 

77 def show_success_message(self, message: str) -> None: 

78 """Display success message to user. 

79 

80 Args: 

81 message: Success message to display 

82 

83 """