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
@@ -174,7 +174,7 @@ func completionContext(cmd *cobra.Command) (context.Context, context.CancelFunc)
|
||||
|
||||
// completeHosts completes the configured instances with their accounts.
|
||||
func (a *application) completeHosts(_ *cobra.Command, _ []string, toComplete string) ([]cobra.Completion, cobra.ShellCompDirective) {
|
||||
snapshot, err := a.deps.Settings.Load()
|
||||
snapshot, err := a.settings()
|
||||
if err != nil {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
@@ -189,7 +189,7 @@ func (a *application) completeHosts(_ *cobra.Command, _ []string, toComplete str
|
||||
func (a *application) completeAccounts(cmd *cobra.Command, _ []string, toComplete string) ([]cobra.Completion, cobra.ShellCompDirective) {
|
||||
ctx, cancel := completionContext(cmd)
|
||||
defer cancel()
|
||||
snapshot, err := a.deps.Settings.Load()
|
||||
snapshot, err := a.settings()
|
||||
if err != nil {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
@@ -244,7 +244,7 @@ func (a *application) completeLocalBranches(cmd *cobra.Command, _ []string, toCo
|
||||
|
||||
// completeAliases completes the configured alias names with their expansions.
|
||||
func (a *application) completeAliases(_ *cobra.Command, _ []string, toComplete string) ([]cobra.Completion, cobra.ShellCompDirective) {
|
||||
snapshot, err := a.deps.Settings.Load()
|
||||
snapshot, err := a.settings()
|
||||
if err != nil {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
@@ -449,7 +449,7 @@ func (a *application) completeRepos() cobra.CompletionFunc {
|
||||
remotes := func(cmd *cobra.Command, _ []string, toComplete string) ([]cobra.Completion, cobra.ShellCompDirective) {
|
||||
ctx, cancel := completionContext(cmd)
|
||||
defer cancel()
|
||||
snapshot, err := a.deps.Settings.Load()
|
||||
snapshot, err := a.settings()
|
||||
if err != nil {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user