-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmain.go
More file actions
47 lines (41 loc) · 978 Bytes
/
main.go
File metadata and controls
47 lines (41 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
Copyright © 2025 raashed
*/
package main
import (
"errors"
"log"
"os"
"github.com/joho/godotenv"
"github.com/rshdhere/vibecheck/cmd"
)
func main() {
// Only try to load .env file if we're not just checking version/help
// This prevents unnecessary log messages during simple --version checks
if !isVersionOrHelp() {
loadDotEnvIfPresent()
}
cmd.Execute()
}
func loadDotEnvIfPresent() {
if _, err := os.Stat(".env"); err != nil {
if !errors.Is(err, os.ErrNotExist) {
log.Printf("unable to stat .env: %v", err)
}
return
}
if err := godotenv.Load(); err != nil {
log.Printf("unable to load .env: %v", err)
}
}
// isVersionOrHelp checks if the command is just asking for version or help
func isVersionOrHelp() bool {
args := os.Args[1:]
for _, arg := range args {
if arg == "--version" || arg == "-v" || arg == "version" ||
arg == "--help" || arg == "-h" || arg == "help" {
return true
}
}
return len(args) == 0 // No args = help
}