def get_multiple( question: str, confirmation: str, value_type: type ) -> List[Union[str, int]]: """Give possibility to user to fill multiple value. Parameters ---------- question:str First question. confirmation:str Asking text if user want to add another. value_type:type The type of values inside the list. Returns ------- List[Union[str, int]] List containing user filled values. """ prompt: Union[IntPrompt, Prompt] = ( IntPrompt() if value_type is int else Prompt() ) user_input = prompt.ask(question, console=console) if not user_input: return [] values = [user_input] while ( Prompt.ask( confirmation, choices=["y", "n"], default="n", console=console ) != "n" ): new = prompt.ask("Other") if new not in values: values.append(new) else: console.print( f"[prompt.invalid]" f"ERROR: `{new}` is already present, [i]ignored[/i]" ) return values
def get_extra(question: str, value_type: type) -> Union[str, int]: prompt: Union[IntPrompt, Prompt] = ( IntPrompt() if value_type is int else Prompt() ) return prompt.ask(question, console=console)