2121import functools
2222import re
2323import sys
24- from typing import Any , Callable , Dict , Tuple
24+ from typing import Any , Callable , Dict , Optional , Tuple
2525
2626import gitlab .config
2727
3636
3737
3838def register_custom_action (
39- cls_names , mandatory : Tuple [Any , ...] = tuple (), optional : Tuple [Any , ...] = tuple ()
39+ cls_names ,
40+ mandatory : Tuple [Any , ...] = tuple (),
41+ optional : Tuple [Any , ...] = tuple (),
42+ custom_action : Optional [str ] = None ,
4043) -> Callable :
41- def wrap (f ) -> Callable :
44+ def wrap (f , custom_action : Optional [ str ] = custom_action ) -> Callable :
4245 @functools .wraps (f )
4346 def wrapped_f (* args , ** kwargs ):
4447 return f (* args , ** kwargs )
@@ -57,7 +60,7 @@ def wrapped_f(*args, **kwargs):
5760 if final_name not in custom_actions :
5861 custom_actions [final_name ] = {}
5962
60- action = f .__name__ .replace ("_" , "-" )
63+ action = custom_action or f .__name__ .replace ("_" , "-" )
6164 custom_actions [final_name ][action ] = (mandatory , optional , in_obj )
6265
6366 return wrapped_f
0 commit comments