Browse Source

Gracefully handles too few arguments in cmd/issues.go

arianagiroux 3 tuần trước cách đây
mục cha
commit
7b36ea66bb
1 tập tin đã thay đổi với 7 bổ sung2 xóa
  1. 7 2
      cmd/issues.go

+ 7 - 2
cmd/issues.go

@@ -22,9 +22,14 @@ func main() {
 	flag.Parse()
 	arg := flag.Args()
 
-	bug, _ := issues.Issue.NewFromPath(issues.Issue{}, arg[0])
+	if len(arg) == 0 {
+		fmt.Println("Not enough args:", arg)
+		os.Exit(1)
+	}
+
+	issue, _ := issues.Issue.NewFromPath(issues.Issue{}, arg[0])
 	p := tea.NewProgram(
-		issues.Model{Issue: bug},
+		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
 	)