issues.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // TODO implement interface for browse bugs in folder
  2. //
  3. // For example:
  4. // If the user provides the path of a folder that matches spec for a bug,
  5. // just display that bug. Otherwise treat the specified path as a collection
  6. // of bugs.
  7. //
  8. // See Also:
  9. // - charmbracelet/bubbles directory and tree explorer
  10. package main
  11. import (
  12. "flag"
  13. "fmt"
  14. "issues"
  15. "os"
  16. tea "github.com/charmbracelet/bubbletea"
  17. )
  18. func main() {
  19. flag.Parse()
  20. arg := flag.Args()
  21. if len(arg) == 0 {
  22. fmt.Println("Not enough args:", arg)
  23. os.Exit(1)
  24. }
  25. isIssue, _ := issues.IsIssue(arg[0])
  26. if isIssue {
  27. issue, err := issues.Issue.NewFromPath(issues.Issue{}, arg[0])
  28. if err != nil {
  29. fmt.Println("could not load issue:", err)
  30. os.Exit(1)
  31. }
  32. p := tea.NewProgram(
  33. issues.Model{Issue: issue},
  34. tea.WithAltScreen(), // use the full size of the terminal in its "alternate screen buffer"
  35. // tea.WithMouseCellMotion(), // turn on mouse support so we can track the mouse wheel
  36. )
  37. if _, err := p.Run(); err != nil {
  38. fmt.Println("could not run program:", err)
  39. os.Exit(1)
  40. }
  41. }
  42. }