Skip to content

Commit

Permalink
Exit with non-zero status when add fails
Browse files Browse the repository at this point in the history
  • Loading branch information
deanishe committed Aug 6, 2020
1 parent 8146d3a commit acc86d7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"os"
"strings"

"github.com/go-shiori/shiori/internal/core"
Expand Down Expand Up @@ -60,14 +61,14 @@ func addHandler(cmd *cobra.Command, args []string) {
book.ID, err = db.CreateNewID("bookmark")
if err != nil {
cError.Printf("Failed to create ID: %v\n", err)
return
os.Exit(1)
}

// Clean up bookmark URL
book.URL, err = core.RemoveUTMParams(book.URL)
if err != nil {
cError.Printf("Failed to clean URL: %v\n", err)
return
os.Exit(1)
}

// If it's not offline mode, fetch data from internet.
Expand Down Expand Up @@ -99,7 +100,7 @@ func addHandler(cmd *cobra.Command, args []string) {
}

if isFatalErr {
return
os.Exit(1)
}
}
}
Expand All @@ -113,7 +114,7 @@ func addHandler(cmd *cobra.Command, args []string) {
_, err = db.SaveBookmarks(book)
if err != nil {
cError.Printf("Failed to save bookmark: %v\n", err)
return
os.Exit(1)
}

// Print added bookmark
Expand Down

0 comments on commit acc86d7

Please sign in to comment.