Skip to content

Instantly share code, notes, and snippets.

@galligan
Created October 20, 2025 19:50
Show Gist options
  • Save galligan/ef77d3b8efb1435c27fcee72c01825a9 to your computer and use it in GitHub Desktop.
Save galligan/ef77d3b8efb1435c27fcee72c01825a9 to your computer and use it in GitHub Desktop.

Revisions

  1. galligan created this gist Oct 20, 2025.
    101 changes: 101 additions & 0 deletions inquire-migration-issue.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,101 @@
    # Migrate CLI prompts from dialoguer to inquire

    ## Overview

    Replace `dialoguer` with `inquire` for interactive CLI prompts to gain better API ergonomics, type safety, and enhanced features.

    ## Current State

    We currently use `dialoguer = "0.11"` in 3 files with 7 total usages:
    - **`remove.rs`**: Single `Confirm` prompt (line 152)
    - **`lookup.rs`**: `Select` and `Input` prompts (lines 243, 256)
    - **`create_source.rs`**: `Confirm`, `Input`, `MultiSelect` (multiple usages)

    ## Why Migrate?

    ### Technical Benefits
    - **Better API ergonomics**: Non-fallible instantiation, cleaner configuration chaining
    - **Built-in type safety**: `CustomType<T>` for parsing numbers, UUIDs, etc.
    - **Validator macros**: `required!()`, `min_length!()`, `max_length!()` for better UX
    - **Native autocompletion**: Built-in fuzzy matching for `Text` prompts
    - **More features**: Editor prompts, DateSelect (via feature flags)
    - **Active maintenance**: v0.9.1 (Sept 2024), 6.9M+ downloads

    ### Migration Effort
    - **Low risk**: Only 3 files, ~100 lines of code
    - **Zero breaking changes**: Same CLI behavior for users
    - **Compatible**: Uses crossterm (already in our stack)
    - **Tests preserved**: Existing test abstraction layer continues to work

    ## Implementation Plan

    ### Phase 1: Setup
    - Add `inquire = "0.9"` to workspace dependencies
    - Update `blz-cli/Cargo.toml` to use workspace version

    ### Phase 2: Migrate Commands (Stacked PRs)

    **PR 1: Migrate `remove.rs`** ⭐ Simplest
    - Replace `dialoguer::Confirm``inquire::Confirm`
    - Update API: `.interact()``.prompt()`, `.default()``.with_default()`
    - Verify tests pass

    **PR 2: Migrate `lookup.rs`** ⭐⭐ Moderate
    - Replace `dialoguer::Select``inquire::Select`
    - Replace `dialoguer::Input``inquire::Text`
    - Update interactive selection and alias input logic

    **PR 3: Migrate `create_source.rs`** ⭐⭐⭐ Most Complex
    - Replace `dialoguer::Confirm``inquire::Confirm`
    - Replace `dialoguer::Input``inquire::Text`
    - Replace `dialoguer::MultiSelect``inquire::MultiSelect`

    ### Phase 3: Cleanup
    - Remove `dialoguer` from dependencies
    - Run full test suite
    - Update CHANGELOG.md

    ## API Comparison

    ### Before (dialoguer)
    ```rust
    use dialoguer::Confirm;

    let confirmed = Confirm::new()
    .with_prompt("Remove source?")
    .default(false)
    .interact()?;
    ```

    ### After (inquire)
    ```rust
    use inquire::Confirm;

    let confirmed = Confirm::new("Remove source?")
    .with_default(false)
    .prompt()?;
    ```

    ## Acceptance Criteria

    - [ ] `inquire` added as workspace dependency
    - [ ] `remove.rs` migrated and tests passing
    - [ ] `lookup.rs` migrated and tests passing
    - [ ] `create_source.rs` migrated and tests passing
    - [ ] `dialoguer` removed from dependencies
    - [ ] All integration tests pass
    - [ ] CHANGELOG.md updated with migration note

    ## Future Enhancements (Separate Issues)

    After migration, we can leverage inquire's advanced features:
    1. Add validation macros for better error messages
    2. Add autocompletion to alias input prompts
    3. Use `CustomType` for numeric inputs
    4. Consider Editor prompt for long descriptions

    ## References

    - inquire docs: https://docs.rs/inquire/0.9.1/inquire/
    - Comparison article: https://fadeevab.com/comparison-of-rust-cli-prompts/
    - GitHub: https://github.com/mikaelmello/inquire