Browse Source

Fixed a fatal bug in issues.go

arianagiroux 2 weeks ago
parent
commit
dd888757ad
1 changed files with 7 additions and 10 deletions
  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)
 	}