File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 2323 "text" : [required ]
2424}
2525
26+ def strip_handler (handler , strip_input ):
27+ def wrapped (params ):
28+ result = handler (params )
29+ if strip_input and isinstance (result , str ):
30+ return result .strip ()
31+ return result
32+ return wrapped
33+
2634INPUT_HANDLERS = {
2735 "choice" : lambda params : select (** params ).execute (),
2836 "file" : lambda params : filepath (** params ).execute (),
@@ -43,6 +51,7 @@ def get_input(
4351 instruction = "" ,
4452 mandatory = True ,
4553 allow_comma_separated = True ,
54+ strip_input = True ,
4655 ** kwargs
4756):
4857 common_params = {
@@ -53,6 +62,7 @@ def get_input(
5362 "style" : style ,
5463 "instruction" : instruction + (":" if instruction else "" ),
5564 "mandatory" : mandatory ,
65+ "transformer" : transformer
5666 }
5767
5868 if validators is None and validate_input :
@@ -82,7 +92,7 @@ def get_input(
8292 if not handler :
8393 raise ValueError (f"Unsupported input_type: { input_type } " )
8494
85- return handler (common_params )
95+ return strip_handler ( handler , strip_input ) (common_params )
8696
8797def get_confirm (
8898 message ,
You can’t perform that action at this time.
0 commit comments