Skip to content

Commit

Permalink
lichen_cli: Add timezone prompt
Browse files Browse the repository at this point in the history
Signed-off-by: Ikey Doherty <[email protected]>
  • Loading branch information
ikeycode committed Jun 19, 2024
1 parent c5a2f2a commit 879620b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lichen_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition = "2021"

[dependencies]
color-eyre.workspace = true
chrono-tz.workspace = true
dialoguer = { version = "0.11.0", features = ["completion", "fuzzy-matcher", "fuzzy-select"] }
indicatif = "0.17.8"
futures.workspace = true
Expand Down
16 changes: 16 additions & 0 deletions lichen_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ fn ask_disk(disks: &[Disk]) -> color_eyre::Result<&Disk> {
Ok(&disks[index])
}

fn ask_timezone() -> color_eyre::Result<String> {
print_header("🕒", "Now we need to set the system timezone");

let index = dialoguer::FuzzySelect::with_theme(&ColorfulTheme::default())
.with_prompt("Start typing")
.items(&chrono_tz::TZ_VARIANTS)
.default(0)
.highlight_matches(true)
.max_length(10)
.interact()?;

Ok(chrono_tz::TZ_VARIANTS[index].to_string())
}

#[tokio::main]
async fn main() -> color_eyre::Result<()> {
color_eyre::install().unwrap();
Expand All @@ -85,11 +99,13 @@ async fn main() -> color_eyre::Result<()> {

let selected_disk = ask_disk(&disks)?;
let selected_locale = ask_locale(&locales).await?;
let timezone = ask_timezone()?;
let _ = ask_password()?;

print_header("🕮", "Quickly review your settings");
print_summary_item("Disk", selected_disk);
print_summary_item("Locale", selected_locale);
print_summary_item("Timezone", &timezone);

println!("\n\n");

Expand Down

0 comments on commit 879620b

Please sign in to comment.