Files
gh-actions-cache/cmd/delete.go

57 lines
1.2 KiB
Go
Raw Normal View History

2022-06-11 02:20:36 +05:30
package cmd
import (
"log"
2022-06-11 02:20:36 +05:30
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(deleteCmd)
2022-06-13 11:28:07 +05:30
deleteCmd.Flags().StringP("repo", "R", "", "Select another repository for finding actions cache.")
deleteCmd.Flags().StringP("branch", "B", "", "Filter by branch")
2022-06-11 02:20:36 +05:30
deleteCmd.SetHelpTemplate(getDeleteHelp())
}
var deleteCmd = &cobra.Command{
Use: "delete",
2022-06-13 11:40:06 +05:30
Short: "Delete cache by key",
Long: `Delete cache by key`,
2022-06-11 02:20:36 +05:30
Run: func(cmd *cobra.Command, args []string) {
COMMAND = "delete"
r, _ := cmd.Flags().GetString("repo")
2022-06-11 02:20:36 +05:30
branch, _ := cmd.Flags().GetString("branch")
repo, err := getRepo(r)
if err != nil {
log.Fatal(err)
}
queryParams := generateQueryParams(branch, 30, "", "", "")
deleteCaches(repo, queryParams)
2022-06-11 02:20:36 +05:30
},
}
func getDeleteHelp() string {
return `
gh-actions-cache: Works with GitHub Actions Cache.
USAGE:
2022-06-13 11:40:06 +05:30
gh actions-cache delete <key> [flags]
2022-06-11 02:20:36 +05:30
ARGUMENTS:
key cache key which needs to be deleted
FLAGS:
2022-06-13 11:48:33 +05:30
-R, --repo <[HOST/]owner/repo> Select another repository using the [HOST/]OWNER/REPO format
2022-06-11 02:20:36 +05:30
-B, --branch <string> Filter by branch
2022-06-13 11:48:33 +05:30
--confirm Confirm deletion without prompting
2022-06-11 02:20:36 +05:30
INHERITED FLAGS
--help Show help for command
EXAMPLES:
$ gh actions-cache delete Linux-node-f5dbf39c9d11eba80242ac13
`
}