Skip to content

gh run ls: add way to filter returned runs by when they were created #7351

@cawfeecake

Description

@cawfeecake

Describe the feature or problem you’d like to solve

the GitHub REST API to list workflow runs accepts the query parameter created that takes a specifically formatted string to return runs that come before, after, or between some arbitrary datetimes.

gh run ls does not have a way to use this functionality.

Proposed solution

add 2 flags to the gh run ls command:

  • --after <str>
  • --before <str>

that take in a parse-able date or datetime. when 1 of the flags is given, you are returned the runs that come after or before the datetime, not including runs that were created on the given datetime. when used together, --after must be provided a datetime that had occurred in the past relative to --before, and then the runs returned will have been created between those datetimes.

How will it benefit CLI and its users?

the only way to do this now with the gh cli is to use gh api ..., but it would be much more convenient to have it available at the ls function.

Additional context

based on the documentation, when the created query string is only selecting before or after (using > and <), you can either select inclusive (appending =) or exclusive of the given dates, but when selecting a range between 2 dates (using <date_1>..<date_2>) it can only exclude the bounding datetimes.

Question to discuss and get answered...

should the date times provided for --after and --before only pass along a created query string using the exclusive boundary options, use the inclusive option when there is only a single --after or --before flag given, or add a way to toggle inclusive/exclusive-ness (maybe a flag that is only valid when either --after or --before, e.g. --include-input-datetime)?

Author comments

open to changing the approach here, like allowing users to pass in the created string themselves and then validating it client side. i thought having these 2 simply-named flags would make it easier to write and later read what the cmd is doing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIhelp wantedContributions welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions