package main import ( "fmt" "github.com/git-bug/git-bug/cache" "github.com/git-bug/git-bug/repository" "github.com/git-bug/git-bug/termui" "github.com/spf13/cobra" ) // runTerm launches the git-bug terminal UI // It first invalidates the cache to ensure git-bug rebuilds it, // then opens the repository, creates a cache, and runs the termui. func runTerm(repoPath string) error { // Invalidate cache so git-bug is forced to rebuild it invalidateGitBugCache(repoPath) // Open the repository repo, err := repository.OpenGoGitRepo(repoPath, "", nil) if err != nil { return fmt.Errorf("failed to open repository: %w", err) } defer repo.Close() // Create the cache (will rebuild since we invalidated) // Using NewRepoCacheNoEvents to simplify - it waits for all build events cacheInstance, err := cache.NewRepoCacheNoEvents(repo) if err != nil { return fmt.Errorf("failed to create cache: %w", err) } defer cacheInstance.Close() // Run the terminal UI if err := termui.Run(cacheInstance); err != nil { return fmt.Errorf("termui error: %w", err) } return nil } var termCmd = &cobra.Command{ Use: "term", Aliases: []string{"termui", "ui"}, Short: "Launch the terminal UI to browse and edit bugs", Long: `Launch the git-bug terminal UI to browse and edit bugs interactively. This command starts the full-featured terminal interface for managing git-bug issues. It provides a two-pane view with a bug list and detailed bug view, allowing you to browse, create, edit, and comment on bugs. Before starting the UI, the cache is invalidated to ensure git-bug rebuilds it with the latest data. This keeps the 'bug' command and 'git-bug' binary in sync. Examples: bug term # Launch terminal UI in current directory bug termui # Same as above (alias) bug ui # Same as above (alias) bug term --repo /path/to/repo # Launch UI for specific repository`, RunE: func(cmd *cobra.Command, args []string) error { return runTerm(repoPath) }, }