瀏覽代碼

Fixed a fatal bug in issues.go

arianagiroux 2 周之前
父節點
當前提交
dd888757ad
共有 1 個文件被更改,包括 7 次插入10 次删除
  1. 7 10
      cmd/issues.go

+ 7 - 10
cmd/issues.go

@@ -26,15 +26,12 @@ func main() {
 	}
 
 	fileInfo, err := os.Stat(arg[0])
-	if err != nil {
-		fmt.Println("error parsing argument:", err)
-		os.Exit(1)
-	}
-
-	if fileInfo.IsDir() {
-		if !issues.IsIssueCollection(fileInfo.Name()) {
-			fmt.Printf("%s is a directory...\n", arg[0])
-			os.Exit(1)
+	if err == nil { // file exists
+		if fileInfo.IsDir() { // file is dir
+			if !issues.IsIssueCollection(arg[0]) && !issues.IsIssue(arg[0]) { // file is not issue collection and not issue
+				fmt.Printf("%s is a directory...\n", arg[0])
+				os.Exit(1)
+			}
 		}
 	}
 
@@ -44,7 +41,7 @@ func main() {
 		// tea.WithMouseCellMotion(), // turn on mouse support so we can track the mouse wheel
 	)
 
-	if _, err := p.Run(); err != nil {
+	if _, e := p.Run(); e != nil {
 		fmt.Println("could not run program:", err)
 		os.Exit(1)
 	}