summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornytpu <alex@nytpu.com>2021-03-20 10:10:01 -0600
committernytpu <alex@nytpu.com>2021-03-20 10:10:01 -0600
commit6639a4288f704ce94582f96a49b205960fa14800 (patch)
treeb21bf11d96a9bc26ebb22ae764f8099b338e63f2
parent71f087b2ad1b63f2c3d9d2e63ad6649a2e6ccf20 (diff)
Add flags to remove for more fine-grained removals
-rw-r--r--comitium.go14
-rw-r--r--doc/comitium.1.scd13
-rw-r--r--flags.go12
3 files changed, 30 insertions, 9 deletions
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.`,
+ )
)