issues.go 1013 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. if len(arg) > 1 {
  20. fmt.Println("Too many arguments:", arg)
  21. os.Exit(1)
  22. }
  23. fileInfo, err := os.Stat(arg[0])
  24. if err != nil {
  25. fmt.Println("error parsing argument:", err)
  26. os.Exit(1)
  27. }
  28. if fileInfo.IsDir() {
  29. if !issues.IsIssueCollection(fileInfo.Name()) {
  30. fmt.Printf("%s is a directory...\n", arg[0])
  31. os.Exit(1)
  32. }
  33. }
  34. p := tea.NewProgram(
  35. issues.Model{Path: arg[0]},
  36. tea.WithAltScreen(), // use the full size of the terminal in its "alternate screen buffer"
  37. // tea.WithMouseCellMotion(), // turn on mouse support so we can track the mouse wheel
  38. )
  39. if _, err := p.Run(); err != nil {
  40. fmt.Println("could not run program:", err)
  41. os.Exit(1)
  42. }
  43. }