summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-11-11 19:32:34 +0800
committerEltrac <hi@guhub.cn>2025-11-11 19:32:34 +0800
commiteb5d4249c6db97bbbb52fd86c1451be50bb33398 (patch)
treee783bec52b0cea2a216671b211d432f34e3764f5 /main.go
parent085a48a39702e2fed1f771c3fb23c062704957e4 (diff)
fix: make sure to exit when certain error occurs
Diffstat (limited to 'main.go')
-rw-r--r--main.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/main.go b/main.go
index 5b7147c..352517c 100644
--- a/main.go
+++ b/main.go
@@ -19,9 +19,7 @@ func main() {
Action: func(ctx context.Context, cmd *cli.Command) error {
// check args
if cmd.Args().Len() == 0 {
- color.Red("❌ Please provide a formulae/cask name.")
- fmt.Println("Usage: wthis <name>")
- return nil
+ printErrorAndExit("Please provide a formulae/cask name.")
}
pkgName := cmd.Args().First()
// prompt
@@ -40,3 +38,9 @@ func main() {
log.Fatal(err)
}
}
+
+func printErrorAndExit(msg string) {
+ hideLoadingPrompt()
+ color.Red("❌ %s", msg)
+ os.Exit(1)
+}