mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
refactor: load settings once per run and reuse shared helpers
The application caches the settings snapshot and reloads it only after an update through the store, so output and prompt helpers no longer read and parse config.yml and hosts.yml several times per command. canPrompt and chooser replace the inline prompt-policy checks. Checks are tallied by one services.Tally, terminal.Plural replaces the two app copies, refKind.article/noun replace the comment group's own words, list commands use servicePage, and web URLs are built by repositoryURL and webURL in browser.go. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
42 files changed
+157
-204
No files matched your search
@@ -99,7 +99,7 @@ list shows identify notification threads; they are not issue numbers.`}
|
||||
}, func(item services.Notification) string { return fmt.Sprintf(mark.done, notificationLabel(item)) })
|
||||
}
|
||||
what := notificationsWith(filters) + " " + s.where
|
||||
if settings, err := a.deps.Settings.Load(); err == nil && a.policy(settings).CanPrompt(a.deps.Streams) {
|
||||
if a.canPrompt() {
|
||||
if err := a.confirmAction(cmd, terminal.Confirmation{Prompt: fmt.Sprintf(mark.ask, what), DefaultYes: true}); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -115,7 +115,7 @@ list shows identify notification threads; they are not issue numbers.`}
|
||||
a.warn(cmd, "No %s", what)
|
||||
return nil
|
||||
}
|
||||
a.done(cmd, mark.done, plural(len(results), "notification"))
|
||||
a.done(cmd, mark.done, terminal.Plural(len(results), "notification"))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
@@ -176,7 +176,7 @@ $ tea notification list --type pull --since 24h`,
|
||||
what := notificationsWith(opts.Statuses) + " " + s.where
|
||||
return writeTable(a, cmd, page.Items, listSpec[services.Notification]{
|
||||
Columns: notificationColumns, Row: notificationRow, Empty: "no " + what, Context: what,
|
||||
}, listPage{Number: opts.Page, More: page.More, Total: page.Total, Counted: page.Counted})
|
||||
}, servicePage(page, opts.Page))
|
||||
},
|
||||
}
|
||||
notificationFilters(command, &opts, &updated)
|
||||
|
||||
Reference in new issue
Block a user