AOSC-Dev / ciel-rs

A tool for controlling AOSC OS packaging environments using multi-layer filesystems and containers (version 3)
MIT License
8 stars 5 forks source link

prompts: use `interact_text` instead of `interact` #14

Closed RedL0tus closed 1 year ago

RedL0tus commented 1 year ago

This change enables the use of arrow keys during ciel new and ciel config.

Dialoguer's documentation doesn't clearly state the difference between the two methods. When dealing with arrow key presses, interact records them as characters, whereas interact_text moves the cursor accordingly.

Demo

#!/usr/bin/env cargo-play

//# dialoguer = "0.10"

use dialoguer::theme::ColorfulTheme;
use dialoguer::Input;

fn main() {
    let theme = ColorfulTheme::default();
    let input: String = Input::with_theme(&theme)
        .with_prompt("Arrow keys work here")
        .interact_text()
        .unwrap();
    println!("Result: {}", input);
    let _: String = Input::with_theme(&theme)
        .with_prompt("UwU Senpai")
        .interact()
        .unwrap();
    println!("Result: {}", input);
}