Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@vilmibm
Copy link
Contributor

@vilmibm vilmibm commented Sep 8, 2020

This PR adds support for a new configuration setting, prompt, with supported values auto and never.

I tried to track down all the commands that prompt and updated:

  • pr create
  • pr merge
  • pr review
  • auth login
  • auth logout
  • auth refresh
  • issue create
  • repo create
  • repo fork

I didn't add new tests for the most part since I was just tweaking the code paths already in place for non-tty support.

It's also worth noting that this cannot be configured per-host, something I call out in the default config comments.

Closes #1587

@tranthanhgiang145

This comment has been minimized.

the behavior for nontty vs. prompts disabled is pretty different so i
opted for a new test, here
@vilmibm vilmibm changed the title [WIP] cfg for disabling prompts Support "prompt" config setting Sep 10, 2020
@vilmibm vilmibm marked this pull request as ready for review September 10, 2020 18:34
@ampinsk
Copy link
Contributor

ampinsk commented Sep 10, 2020

One nit: the values of auto and never weren't very intuitive to me. How about enabled and disabled?

Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! This looks good; I've pointed out some minor things that I see as regressions in non-interactive mode.

The only overall direction I would change is avoiding saying “when prompts are disabled” in error messages when CanPrompt() returns false, because those messages will also be shown in CI/CD environments and scripts where prompts might have not been disabled per se, but are not available due to lack of terminal. So maybe a better message would be to say “when running non-interactively” or something similar?

return fmt.Errorf("failed to write config, authentication configuration not updated: %w", err)
}

isTTY := opts.IO.IsStdinTTY() && opts.IO.IsStdoutTTY()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could also name these tty checks something more descriptive that declares intent, like opts.IO.ShouldShowConfirmation() (ideally with a better name). Perhaps in a separate changeset!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of an IO.ShowConfirmations()! i'll open an issue for it.

return &cmdutil.FlagError{Err: errors.New("must pass name argument when prompts disabled")}
}
if !opts.Internal && !opts.Private && !opts.Public {
opts.Public = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly feel that we should either default to --private or error out in non-interactive mode when repo visibility wasn't explicitly declared.

Copy link
Contributor Author

@vilmibm vilmibm Sep 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaulting to private feels right to me, but didn't we get multiple issues complaining about not defaulting to public for repo creation? or am I misremembering?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set it to error now, happy to update to something else later. I figured the annoyance of getting an error is better than the annoyance of having to go to the browser and toggle the repo visibility if the default isn't what you wanted.

@vilmibm vilmibm merged commit 5a8df47 into trunk Sep 11, 2020
@samcoe samcoe deleted the disable-prompts branch September 17, 2020 15:13
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.

Add a config to disable prompts

4 participants