clikt icon indicating copy to clipboard operation
clikt copied to clipboard

Disable prompt options on non-interactive terminals

Open RafeArnold opened this issue 4 months ago • 1 comments

Clikt's prompt option capabilities are great, but prompting the user for input is not possible in non-interactive terminals. When this is the case, it seems logical to have prompt options fallback to being simple required options. I understand this can be done manually with something like

.run {
  if (interactive) {
    prompt(text = "username")
  } else {
    required()
  }
}

but seems like an obvious default to me that is within Clikt's remit, so could alleviate a pitfall for the library user with relative ease, and I believe would align with clig's guidelines.

Of course, there may be a totally valid reason for this not already being implemented that I'm missing and there may also be backwards compatibility concerns, so happy to take this to a discussion thread if that's more appropriate.

I'm happy to submit a PR for this myself if its deemed a good change.

RafeArnold avatar Oct 14 '25 08:10 RafeArnold

Sure, I think that makes sense. I'd accept a PR!

ajalt avatar Oct 14 '25 15:10 ajalt