diff --git a/comitium.go b/comitium.go index 7a02521..08d026c 100644 --- a/comitium.go +++ b/comitium.go @@ -104,12 +104,11 @@ func main() { } case "remove": argCheck(c.Args(), 1, true, "Please provide a URL to remove.") - delete(core.Data.Feeds, c.Arg(0)) - 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) + if (!*removeFeedsFlag && !*removePagesFlag) || *removeFeedsFlag { + delete(core.Data.Feeds, c.Arg(0)) + } + if (!*removeFeedsFlag && !*removePagesFlag) || *removePagesFlag { + delete(core.Data.Pages, c.Arg(0)) } } @@ -182,7 +181,8 @@ func usage() { fmt.Fprintf(os.Stderr, "\nGlobal Flags:\n%v", globalFs.FlagUsages()) // command-specific flags should be printed here fmt.Fprintf(os.Stderr, "Flags for \"add\":\n%v", commands["add"].FlagUsages()) - fmt.Fprintf(os.Stderr, "Flags for \"refresh\":\n%v\n", commands["refresh"].FlagUsages()) + fmt.Fprintf(os.Stderr, "Flags for \"refresh\":\n%v", commands["refresh"].FlagUsages()) + fmt.Fprintf(os.Stderr, "Flags for \"remove\":\n%v\n", commands["remove"].FlagUsages()) fmt.Fprint(os.Stderr, "For more help, see comitium(1).\n") } diff --git a/doc/comitium.1.scd b/doc/comitium.1.scd index fe70106..b958167 100644 --- a/doc/comitium.1.scd +++ b/doc/comitium.1.scd @@ -38,8 +38,9 @@ variety of feed formats: *refresh* afterwards, *add* will automatically fetch the entries and regenerate the .gmi and .json files. -*remove* <_LINK_> - Remove a subscription at _LINK_. +*remove* [_FLAGS_] <_LINK_> + Remove a subscription at _LINK_. Will remove from both subscribed feeds and + subscribed pages by default. *help* Print basic usage information, including a list of commands and flags with @@ -73,6 +74,14 @@ command-specific flags that are not universally recognized. Watch a page for changes instead of adding as a feed. Useful for gophermaps, or gemini/http resources with no parseable feed. +## REMOVE FLAGS + +*-f*, *--feeds* + Remove the URL from subscribed feeds. + +*-p*, *--pages* + Remove the URL from subscribed pages. + # ENVIRONMENT VARIABLES *COMITIUM_DATA* diff --git a/flags.go b/flags.go index e9bd942..5fcba98 100644 --- a/flags.go +++ b/flags.go @@ -52,4 +52,16 @@ var ( `Number of worker threads to use when refreshing feeds. More is faster, but there are more concurrent outgoing requests then.`, ) + + // remove + removeFeedsFlag = commands["remove"].BoolP( + "feeds", "f", + false, + `Remove URL from subscribed feeds.`, + ) + removePagesFlag = commands["remove"].BoolP( + "pages", "p", + false, + `remove URL from subscribed pages.`, + ) )