github.com/scaleway/scaleway-cli@v1.11.1/pkg/cli/x_flushcache.go (about) 1 // Copyright (C) 2015 Scaleway. All rights reserved. 2 // Use of this source code is governed by a MIT-style 3 // license that can be found in the LICENSE.md file. 4 5 package cli 6 7 import "fmt" 8 9 var cmdFlushCache = &Command{ 10 Exec: runFlushCache, 11 UsageLine: "_flush-cache [OPTIONS]", 12 Description: "", 13 Hidden: true, 14 Help: "Flush cache", 15 } 16 17 func init() { 18 cmdFlushCache.Flag.BoolVar(&flushCacheHelp, []string{"h", "-help"}, false, "Print usage") 19 } 20 21 // Flags 22 var flushCacheHelp bool // -h, --help flag 23 24 func runFlushCache(cmd *Command, args []string) error { 25 if flushCacheHelp { 26 return cmd.PrintUsage() 27 } 28 if len(args) > 0 { 29 return cmd.PrintShortUsage() 30 } 31 32 err := cmd.API.Cache.Flush() 33 if err != nil { 34 return fmt.Errorf("Failed to flush the cache") 35 } 36 fmt.Println("Cache flushed") 37 return nil 38 }