When trying to give an Option with a prompt value, keep asking for a value. #603
-
        First Check
 Commit to Help
 Example Codedef generateConfigFile(server:str, database:str, user:str, password:str):
    
    configurations: dict[str,str] = {
        'Server': server,
        'Database': database,
        'User': user,
        'Password': password
    }
    with open ('config.yaml','wt',encoding="utf-8") as file:
        yaml.dump(configurations,file)
  
@app.command()
def config(server:str = typer.Option(..., prompt_required=True, prompt=True),
           database:str = typer.Option(..., prompt_required=True, prompt=True),
           user: str = typer.Option(..., prompt_required=False, prompt=True),
           password: str =  typer.Option(..., prompt_required=False, prompt=True, hide_input=True)):
    """
    Run this command to install the database configurations
    """
    with Progress(
        SpinnerColumn(),
        TextColumn("[progress.description]{task.description}"),
        transient=True,
    ) as progress:
        progress.add_task(description="Processing...", total=None)
        progress.add_task(description="Preparing...", total=None)
        
        generateConfigFile(server,database,user,password)
        print("Done!")DescriptionI have a similar code as above that generates a configuration file, but I would like to have the option to have empty user and empty password. When I run my application: Server: myServer If I want to have the option empty, the application keep asking for a parameter, but I would like the application to recognize the empty string, or what workaround can I use for that? I wouldn't want to use the input function, just want to know if there is a typer option to do that Operating SystemWindows Operating System DetailsNo response Typer Version0.7.0 Python Version3.9.13 Additional ContextNo response  | 
  
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
| 
         Neverminded I figured it out 🙈, I just set the following parameters typer.Option(default="", show_default=False, prompt=True, hide_input=True)).  | 
  
Beta Was this translation helpful? Give feedback.
Neverminded I figured it out 🙈, I just set the following parameters typer.Option(default="", show_default=False, prompt=True, hide_input=True)).