browse

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cobra.Command{
	Use:   "browse PATH",
	Short: "Browse a repository",
	Args:  cobra.MaximumNArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		rp := "."
		if len(args) > 0 {
			rp = args[0]
		}

		abs, err := filepath.Abs(rp)
		if err != nil {
			return err
		}

		r, err := git.Open(abs)
		if err != nil {
			return fmt.Errorf("failed to open repository: %w", err)
		}

		output := lipgloss.DefaultRenderer()
		ctx := cmd.Context()
		c := common.NewCommon(ctx, output, 0, 0)
		c.HideCloneCmd = true
		comps := []common.TabComponent{
			repo.NewReadme(c),
			repo.NewFiles(c),
			repo.NewLog(c),
		}
		if !r.IsBare {
			comps = append(comps, repo.NewStash(c))
		}
		comps = append(comps, repo.NewRefs(c, git.RefsHeads), repo.NewRefs(c, git.RefsTags))
		m := &model{
			model:  repo.New(c, comps...),
			repo:   repository{r},
			common: c,
		}

		m.footer = footer.New(c, m)
		p := tea.NewProgram(m,
			tea.WithAltScreen(),
			tea.WithMouseCellMotion(),
		)

		_, err = p.Run()
		return err
	},
}

Command is the browse command.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL