aboutsummaryrefslogtreecommitdiff
path: root/internal/commands/drop.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/commands/drop.go')
-rw-r--r--internal/commands/drop.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/commands/drop.go b/internal/commands/drop.go
new file mode 100644
index 0000000..58855df
--- /dev/null
+++ b/internal/commands/drop.go
@@ -0,0 +1,24 @@
+package commands
+
+import (
+ "fmt"
+
+ "github.com/Fuwn/yae/internal/yae"
+ "github.com/urfave/cli/v2"
+)
+
+func Drop(sources *yae.Sources) func(c *cli.Context) error {
+ return func(c *cli.Context) error {
+ if c.Args().Len() == 0 {
+ return fmt.Errorf("invalid number of arguments")
+ }
+
+ if !sources.Exists(c.Args().Get(0)) {
+ return fmt.Errorf("source does not exist")
+ }
+
+ sources.Drop(c.Args().Get(0))
+
+ return sources.Save(c.String("sources"))
+ }
+}