reduce repetition and inconsistency when writing subs and feeds.gmi
This commit is contained in:
+10
-26
@@ -57,28 +57,8 @@ func main() {
|
||||
case "refresh":
|
||||
argCheck(c.Args(), 0, false, "'refresh' doesn't take an argument!")
|
||||
fetch.RefreshAll(&core.Data, *refreshWorkersFlag)
|
||||
err = core.Data.WriteSubs(dataPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error writing subscriptions: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
err = core.Data.WriteFeed(dataPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error writing feed: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
case "regenerate":
|
||||
argCheck(c.Args(), 0, false, "'regenerate' doesn't take an argument!")
|
||||
err = core.Data.WriteSubs(dataPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error writing subscriptions: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
err = core.Data.WriteFeed(dataPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error writing feed: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
case "add":
|
||||
argCheck(c.Args(), 1, true, "Please provide a URL to add.")
|
||||
|
||||
@@ -97,11 +77,6 @@ func main() {
|
||||
fmt.Fprintf(os.Stderr, "Error adding URL: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
err = core.Data.WriteSubs(dataPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error saving subscriptions: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
case "remove":
|
||||
argCheck(c.Args(), 1, true, "Please provide a URL to remove.")
|
||||
if (!*removeFeedsFlag && !*removePagesFlag) || *removeFeedsFlag {
|
||||
@@ -111,7 +86,16 @@ func main() {
|
||||
delete(core.Data.Pages, c.Arg(0))
|
||||
}
|
||||
}
|
||||
|
||||
err = core.Data.WriteSubs(dataPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error saving subscriptions: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
err = core.Data.WriteFeed(dataPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error writing feed: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
err = core.Data.WriteJSON(dataPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error saving subscriptions json: %v\n", err)
|
||||
|
||||
Reference in New Issue
Block a user