issues.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 { // file exists
  25. if fileInfo.IsDir() { // file is dir
  26. if !issues.IsIssueCollection(arg[0]) && !issues.IsIssue(arg[0]) { // file is not issue collection and not issue
  27. fmt.Printf("%s is a directory...\n", arg[0])
  28. os.Exit(1)
  29. }
  30. }
  31. }
  32. p := tea.NewProgram(
  33. issues.Model{Path: arg[0]},
  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 _, e := p.Run(); e != nil {
  38. fmt.Println("could not run program:", err)
  39. os.Exit(1)
  40. }
  41. }