Skip to content

Fix --interval option docs in pr checks #11999

Description

@babakks

Just noticed the usage doc for the --interval flag in pr checks shows --watch as placeholder:

$ gh pr checks --help
...
  -i, --interval --watch   Refresh interval in seconds when using --watch flag (default 10)
...

This has to be fixed into something like this:

  -i, --interval int   Refresh interval in seconds when using --watch flag (default 10)

Activity

  1. 2003Aditya commented on Oct 25, 2025

    @2003Aditya
    Contributor

    Hey @babakks! can i work on this ?

  2. babakks commented on Oct 25, 2025

    @babakks
    MemberAuthor

    Hi @2003Aditya! Thanks for your offering. 🙏 However, we didn't label this with help wanted Contributions welcome since we need to fx this quickly before the next release. If you can make it, feel free to submit a PR. I think this is a special case.

    Also, please note that our preference is to keep the backticks around --watch, so that we can render it correctly on our docs website. It's not really nice at the moment, but keeping the backticks would help when we have fixed the issue with the website docs.

    By the way, this seems to be a behaviour in Cobra.

  3. 2003Aditya commented on Oct 26, 2025

    @2003Aditya
    Contributor

    Hey @babakks, thanks for the clarification! 🙏

    Sorry, I missed that the issue wasn’t labeled help wanted earlier. I kept the backticks around --watch as you mentioned. However, when I do that, Cobra still shows the placeholder as --watch instead of int.

    Since this seems to be a behavior from Cobra, could you please guide me on how you’d prefer handling this fix within gh? I’d like to align it exactly with your expectations.

  4. babakks commented on Oct 26, 2025

    @babakks
    MemberAuthor

    Yeah, it's what Cobra does. I need to dive in the Cobra code and see if there's any way to workaround/disable the behaviour. For now, I guess just simplifying the usage string is fine.

    FWIW this is where the usage string is parsed in spf13/pflag:
    https://github.com/spf13/pflag/blob/6fcfbc9910e1af538fde31db820be7d1bec231e4/flag.go#L589-L633

  5. 2003Aditya commented on Oct 28, 2025

    @2003Aditya
    Contributor

    Hey @babakks 👋

    I was thinking of going with this approach to fix the placeholder issue while keeping the backticks for proper docs rendering:

    cmd.Flags().IntVarP(&interval, "interval", "i", 10, "Refresh interval in seconds when using --watch flag")
    
    if f := cmd.Flags().Lookup("interval"); f != nil {
        f.Usage = "Refresh interval in seconds when using `--watch` flag"
    }
    

    This way, Cobra won’t replace the placeholder with --watch in the CLI help output, but the backticks will still be preserved for the website docs.

    Does this look good to you

  6. babakks commented on Oct 28, 2025

    @babakks
    MemberAuthor

    @2003Aditya, this works but I'd rather keep it simple, like other flags, and avoid overriding Cobra like this.

  7. 2003Aditya commented on Oct 29, 2025

    @2003Aditya
    Contributor

    @babakks can i do this #12021 (comment) and make the PR?

  8. babakks commented on Oct 29, 2025

    @babakks
    MemberAuthor

    Yup, go ahead.

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

Metadata

Metadata

Assignees

Labels

docsgh-prrelating to the gh pr command

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions