Skip to content

Use duration for --debounce-ms in watch #16178

Closed

Description

@lucascherzer

Related problem

Currently, watch uses an int to define the --debounce-ms.

Describe the solution you'd like

Since nu already has a builtin duration type, this would perhaps better fit the use case. It would make for a more consistent and flexible CLI:

watch --debounce 5min . { "Something changed" | print }

Describe alternatives you've considered

You could manually convert the time to ms before calling watch:

watch . --debounce-ms ((5min / 1ms) | math round) { "Something changed" | print }

Additional context and details

If this is implemented, we need to add watch to the list of commands using Duration in the docs:

Also, if this is implemented, we need to think about deprecation. Do we remove the old flag entirely? this would break many existing scripts. Do we instead keep the old flag and simply add a new one? Imo the best option.
And how do we handle the short flag -d?

Activity

  1. added
    category:enhancement
    status:needs-triage
    on Jul 15, 2025
  2. added
    A:datetime-handling
    on Jul 15, 2025
  3. sholderbach commented on Jul 16, 2025

    @sholderbach
    Member

    Good call, yes this should probably migrate over to --debounce: duration.
    For the deprecation, as we are pre-stable, we can remove the old flag after some deprecation period.

    The procedure would be to add the new --debounce flag, and emit a deprecation warning when using the old variant, with the warning that it will be removed in an upcoming release. After that flag deprecation warning was active for a bit (for something like this we tend to only go for a one release deprecation period) we can remove it entirely. In the interim there should probably also be an error when you try to use both or a clarification which takes precedent.

  4. added
    good first issue
    and removed
    status:needs-triage
    on Jul 16, 2025
  5. lucascherzer commented on Jul 16, 2025

    @lucascherzer
    ContributorAuthor

    Great. How do you think we best go about the -p flag?
    Have it be bound to --debounce-ms during the deprecation period and then switch to --debounce?

  6. Bahex commented on Jul 16, 2025

    @Bahex
    Member

    @lucascherzer It should be okay switch -d to mean --debounce right after --debounce-ms is removed, since code that hasn't been updated will throw a type error and not act in unexpected ways 👍

  7. lucascherzer commented on Jul 16, 2025

    @lucascherzer
    ContributorAuthor

    I will have a go at this once I'm off work

  8. added this to the v0.107.0 milestone on Jul 29, 2025
  9. added a commit that references this issue on Jul 29, 2025
    459f3c0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:datetime-handlingcategory:enhancementgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions