blob: 788b62b22be020038808af197fc953062f63bac5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package commands
import (
"fmt"
"github.com/Fuwn/yae/internal/yae"
"github.com/urfave/cli/v2"
)
func Drop(sources *yae.Environment) 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))
if c.Bool("dry-run") {
return nil
}
return sources.Save(c.String("sources"))
}
}
|