issues.go 1.1 KB

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 { // 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. } else {
  31. fmt.Printf("%s is an existing file...\n", arg[0])
  32. os.Exit(1)
  33. }
  34. }
  35. p := tea.NewProgram(
  36. issues.Model{Path: arg[0]},
  37. tea.WithAltScreen(), // use the full size of the terminal in its "alternate screen buffer"
  38. // tea.WithMouseCellMotion(), // turn on mouse support so we can track the mouse wheel
  39. )
  40. if _, e := p.Run(); e != nil {
  41. fmt.Println("could not run program:", err)
  42. os.Exit(1)
  43. }
  44. }