55
66from  beartype  import  beartype   # pyright: ignore [reportUnknownVariableType] 
77
8+ from  mac_cleanup  import  args 
89from  mac_cleanup .progress  import  ProgressBar 
910from  mac_cleanup .utils  import  check_deletable , check_exists , cmd 
1011
@@ -27,6 +28,9 @@ def with_prompt(self: T, message_: Optional[str] = None) -> T:
2728        :class: `BaseModule` 
2829        """ 
2930
31+         if  args .force :
32+             return  self 
33+ 
3034        # Can't be solved without typing.Self 
3135        self .__prompt  =  True   # pyright: ignore [reportGeneralTypeIssues] 
3236
@@ -73,11 +77,11 @@ def get_command(self) -> Optional[str]:
7377        return  self .__command 
7478
7579    @abstractmethod  
76-     def  _execute (self , ** kwargs : bool ) ->  Optional [str ]:
80+     def  _execute (self , ignore_errors : bool   =   True ) ->  Optional [str ]:
7781        """ 
7882        Execute the command specified. 
7983
80-         :param ignore_errors_ : Ignore errors during execution 
84+         :param ignore_errors : Ignore errors during execution 
8185        :return: Command execution results based on specified parameters 
8286        """ 
8387
@@ -90,7 +94,7 @@ def _execute(self, **kwargs: bool) -> Optional[str]:
9094            return 
9195
9296        # Execute command 
93-         return  cmd (command = self .__command , ignore_errors = kwargs . get ( " ignore_errors" ,  True ) )
97+         return  cmd (command = self .__command , ignore_errors = ignore_errors )
9498
9599
96100@final  
@@ -106,8 +110,15 @@ def with_errors(self) -> "Command":
106110
107111        return  self 
108112
109-     def  _execute (self ) ->  Optional [str ]:
110-         return  super ()._execute (ignore_errors = self .__ignore_errors )
113+     def  _execute (self , ignore_errors : Optional [bool ] =  None ) ->  Optional [str ]:
114+         """ 
115+         Execute the command specified. 
116+ 
117+         :param ignore_errors: Overrides flag `ignore_errors` in class 
118+         :return: Command execution results based on specified parameters 
119+         """ 
120+ 
121+         return  super ()._execute (ignore_errors = self .__ignore_errors  if  ignore_errors  is  None  else  ignore_errors )
111122
112123
113124@final  
@@ -137,7 +148,7 @@ def dry_run_only(self) -> "Path":
137148
138149        return  self 
139150
140-     def  _execute (self ) ->  Optional [str ]:
151+     def  _execute (self ,  ignore_errors :  bool   =   True ) ->  Optional [str ]:
141152        """Delete specified path :return: Command execution results based on specified 
142153        parameters. 
143154        """ 
@@ -149,4 +160,4 @@ def _execute(self) -> Optional[str]:
149160        if  not  all ([check_deletable (path = self .__path ), check_exists (path = self .__path , expand_user = False )]):
150161            return 
151162
152-         return  super ()._execute ()   # Always ignore errors 
163+         return  super ()._execute (ignore_errors = ignore_errors ) 
0 commit comments