/
x_flushcache.go
38 lines (31 loc) · 822 Bytes
/
x_flushcache.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
// Copyright (C) 2015 Scaleway. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE.md file.
package cli
import "fmt"
var cmdFlushCache = &Command{
Exec: runFlushCache,
UsageLine: "_flush-cache [OPTIONS]",
Description: "",
Hidden: true,
Help: "Flush cache",
}
func init() {
cmdFlushCache.Flag.BoolVar(&flushCacheHelp, []string{"h", "-help"}, false, "Print usage")
}
// Flags
var flushCacheHelp bool // -h, --help flag
func runFlushCache(cmd *Command, args []string) error {
if flushCacheHelp {
return cmd.PrintUsage()
}
if len(args) > 0 {
return cmd.PrintShortUsage()
}
err := cmd.API.Cache.Flush()
if err != nil {
return fmt.Errorf("Failed to flush the cache")
}
fmt.Println("Cache flushed")
return nil
}