mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
fix: reconcile the repository, platform and admin streams
Share one yesNo helper, drop the unused confirmTyped now that typed confirmations go through confirmAction, keep Markdown raw in view tests through the markdown preference, and print doctor latency in whole milliseconds so fast instances do not show 0s. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
6 files changed
+18
-27
No files matched your search
@@ -416,28 +416,6 @@ func (a *application) confirm(cmd *cobra.Command, description string) error {
|
||||
return terminal.Confirm(cmd.Context(), description, a.options.yes, a.deps.Streams, a.policy(s), a.deps.Prompter)
|
||||
}
|
||||
|
||||
// confirmTyped asks the user to type answer before an irreversible action unless --yes was supplied.
|
||||
func (a *application) confirmTyped(cmd *cobra.Command, description, answer string) error {
|
||||
if a.options.yes {
|
||||
return nil
|
||||
}
|
||||
s, err := a.deps.Settings.Load()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !a.policy(s).CanPrompt(a.deps.Streams) {
|
||||
return clierr.Wrap(clierr.Usage, errors.New("confirmation required: supply --yes"))
|
||||
}
|
||||
typed, err := a.deps.Prompter.Input(cmd.Context(), description+" Type "+answer+" to confirm:")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !strings.EqualFold(strings.TrimSpace(typed), answer) {
|
||||
return clierr.Wrap(clierr.Canceled, errors.New("operation canceled"))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// require prompts for a missing required value under the prompt policy.
|
||||
func (a *application) require(cmd *cobra.Command, value *string, flag string) (bool, error) {
|
||||
s, err := a.deps.Settings.Load()
|
||||
|
||||
Reference in new issue
Block a user