Explorar el Código

Made issues.go check if path passes spec

arianagiroux hace 3 semanas
padre
commit
1ec82502b4
Se han modificado 1 ficheros con 16 adiciones y 9 borrados
  1. 16 9
      cmd/issues.go

+ 16 - 9
cmd/issues.go

@@ -27,15 +27,22 @@ func main() {
 		os.Exit(1)
 	}
 
-	issue, _ := issues.Issue.NewFromPath(issues.Issue{}, arg[0])
-	p := tea.NewProgram(
-		issues.Model{Issue: issue},
-		tea.WithAltScreen(), // use the full size of the terminal in its "alternate screen buffer"
-		// tea.WithMouseCellMotion(), // turn on mouse support so we can track the mouse wheel
-	)
+	isIssue, _ := issues.IsIssue(arg[0])
+	if isIssue {
+		issue, err := issues.Issue.NewFromPath(issues.Issue{}, arg[0])
+		if err != nil {
+			fmt.Println("could not load issue:", err)
+			os.Exit(1)
+		}
+		p := tea.NewProgram(
+			issues.Model{Issue: issue},
+			tea.WithAltScreen(), // use the full size of the terminal in its "alternate screen buffer"
+			// tea.WithMouseCellMotion(), // turn on mouse support so we can track the mouse wheel
+		)
 
-	if _, err := p.Run(); err != nil {
-		fmt.Println("could not run program:", err)
-		os.Exit(1)
+		if _, err := p.Run(); err != nil {
+			fmt.Println("could not run program:", err)
+			os.Exit(1)
+		}
 	}
 }