Skip to content

[Improvement] Initial value for input #95

@Squirreljetpack

Description

@Squirreljetpack
pub fn prompt_tags(_initial: &[String]) -> io::Result<Vec<String>> {
    let res: String = cliclack::input("Enter tags (one per line):")
        .multiline()
        .validate_interactively(|s: &String| {
            for (i, line) in s.lines().enumerate() {
                if line.is_empty() {
                    return Err(format!("line {} is empty", i + 1));
                }
                if !line.is_ascii() {
                    return Err(format!("line {} contains non-ascii characters", i + 1));
                }
            }
            // .initial_input(&initial.join("\n"))
            Ok(())
        })
        .interact()?;
    
    Ok(res.lines().map(|s| s.to_string()).collect())
}

example use case ^: would allow editing with input.
I imagine it would override placeholder and default_value if nonempty.

it's a nice to have on a project of mine so very low priority for me to fork and implement currently, but if it fits the theme of the project id be interested in bumping it up and submitting a pr.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions