Skip to content

Conversation

@2910000
Copy link

@2910000 2910000 commented Jul 29, 2025

This is a work in progress, but I thought this would be a good point to share what I have so far.

The DateTime prompt does most of what I want it to, and the trait changes relating to prompt state should make it easier to add other compound prompts (like a radio button prompt).

That said, working on this demonstrated just how opinionated a prompt that handles date and time has to be.
It may be less of a headache long-term to include the datetime module only in the examples directory, while keeping the code allowing compound state that it's built on.

Please let me know what you think!


What this changes

State traits

Creates a CompoundState, intended as a container to hold the state of multiple child prompts.
Creates a TextualState to hold functionality separate from the container-like CompoundState.
Creates a StateCommon, to hold core functionality shared by all state types.

Validation

  • per-character validation on input (is_valid_char)
  • checking value wrt native type (e.g. for DateTime, chrono::NaiveDateTime) on marking prompt Status as Done

datetime Module

DateTimeState, DateTimePrompt, NumericChildState and NumericPrompt

Styling

The datetime prompt has a default display shown when no text is entered.

Example

20250729_10h54m12s_grim

Adds the utc_time example, which requires the datetime feature:

$ cargo run --features datetime --example utc_time

The status doesn't do anything.

Remaining issues

I haven't written much documentation or any tests for the new code yet.

Validity

No builtin way of checking semantic validity yet.
This is important where the value of one prompt is related to the value of another, or where there is an external constraint.
Does it need to be builtin? I'm not sure

Status

With validation on submission, there is now the possibility for an "invalid" status. I have made no changes to this, so the Status (or more broadly, how status is considered and handled) needs review.

Adding Style

The *RenderStyle types would benefit from more generalisation.

Prompt Sizing

I haven't yet done anything to allow for resizing of the DateTimePrompt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant