-
Notifications
You must be signed in to change notification settings - Fork 13
/
remove.go
42 lines (36 loc) · 1.31 KB
/
remove.go
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) 2016, Ben Morgan. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
package main
import (
"github.com/cassava/repoctl/internal/term"
"github.com/spf13/cobra"
)
func init() {
MainCmd.AddCommand(removeCmd)
}
var removeCmd = &cobra.Command{
Use: "remove PKGNAME ...",
Aliases: []string{"rm"},
Short: "Remove and delete packages from the database",
Long: `Remove and delete the package files from the repository.
This command removes the specified package from the repository
database, and deletes any associated package files, unless the backup
option is given, in which case the package files are moved to the
backup directory.
If the backup directory resolves to the repository directory,
then package files are ignored; repoctl update will add them again.
In this case, you probably want to use a profile with backup=false to force
them to be deleted.
`,
Example: ` repoctl rm fairsplit`,
ValidArgsFunction: completeRepoPackageNames,
PreRunE: ProfileInit,
PostRunE: ProfileTeardown,
RunE: func(cmd *cobra.Command, args []string) error {
if Repo.Backup && Repo.IsObsoleteCached() {
term.Warnf("Warning: removing only database entries\n")
}
return Repo.Remove(nil, args...)
},
}