mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-18 19:16:22 +00:00
* fix: make patch list registry-only * feat: add patch command progress logs * fix: address review feedback for PR #921
62 lines
1.6 KiB
Go
62 lines
1.6 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/browseros-ai/BrowserOS/packages/browseros/tools/patch/internal/engine"
|
|
"github.com/browseros-ai/BrowserOS/packages/browseros/tools/patch/internal/repo"
|
|
"github.com/browseros-ai/BrowserOS/packages/browseros/tools/patch/internal/ui"
|
|
"github.com/browseros-ai/BrowserOS/packages/browseros/tools/patch/internal/workspace"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func repoInfo() (*repo.Info, error) {
|
|
return appState.RepoInfo()
|
|
}
|
|
|
|
func resolveWorkspace(positional []string, src string) (workspace.Entry, error) {
|
|
name := ""
|
|
if len(positional) > 0 {
|
|
name = positional[0]
|
|
}
|
|
return appState.ResolveWorkspace(name, src)
|
|
}
|
|
|
|
func splitWorkspaceAndFilters(cmd *cobra.Command, args []string) ([]string, []string) {
|
|
atDash := cmd.ArgsLenAtDash()
|
|
if atDash == -1 {
|
|
return args, nil
|
|
}
|
|
return args[:atDash], args[atDash:]
|
|
}
|
|
|
|
func ensureRepoConfigured(override string) error {
|
|
if override == "" && appState.Config.PatchesRepo != "" {
|
|
return nil
|
|
}
|
|
root := override
|
|
if root == "" {
|
|
discovered, err := repo.Discover(appState.CWD)
|
|
if err != nil {
|
|
return fmt.Errorf(`unable to discover patches repo; pass --patches-repo or run from packages/browseros`)
|
|
}
|
|
root = discovered
|
|
}
|
|
info, err := repo.Load(root)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
appState.Config.PatchesRepo = info.Root
|
|
return nil
|
|
}
|
|
|
|
// commandProgress routes long-running engine updates to stderr in human mode only.
|
|
func commandProgress(cmd *cobra.Command) engine.Progress {
|
|
if jsonOut {
|
|
return nil
|
|
}
|
|
return engine.ProgressFunc(func(message string) {
|
|
fmt.Fprintf(cmd.ErrOrStderr(), "%s %s\n", ui.Muted("..."), message)
|
|
})
|
|
}
|