issues.go 935 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // TODO implement edit/delete funcs
  2. //
  3. // TODO implement attempt to auto load issues folder if no arg specified
  4. package main
  5. import (
  6. "flag"
  7. "fmt"
  8. "issues"
  9. "os"
  10. tea "github.com/charmbracelet/bubbletea"
  11. )
  12. func main() {
  13. flag.Parse()
  14. arg := flag.Args()
  15. if len(arg) == 0 {
  16. fmt.Println("Not enough arguments:", arg)
  17. os.Exit(1)
  18. }
  19. fileInfo, err := os.Stat(arg[0])
  20. if err != nil {
  21. fmt.Println("could not run program:", err)
  22. os.Exit(1)
  23. }
  24. if fileInfo.IsDir() {
  25. if !issues.IsIssueCollection(fileInfo.Name()) {
  26. fmt.Printf("%s is a directory...\n", arg[0])
  27. os.Exit(1)
  28. }
  29. }
  30. p := tea.NewProgram(
  31. issues.Model{Path: arg[0]},
  32. tea.WithAltScreen(), // use the full size of the terminal in its "alternate screen buffer"
  33. // tea.WithMouseCellMotion(), // turn on mouse support so we can track the mouse wheel
  34. )
  35. if _, err := p.Run(); err != nil {
  36. fmt.Println("could not run program:", err)
  37. os.Exit(1)
  38. }
  39. }