github.com/scaleway/scaleway-cli@v1.11.1/pkg/cli/cmd_rmi.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 "github.com/scaleway/scaleway-cli/pkg/commands" 8 9 var cmdRmi = &Command{ 10 Exec: runRmi, 11 UsageLine: "rmi [OPTIONS] IDENTIFIER [IDENTIFIER...]", 12 Description: "Remove one or more image(s)/volume(s)/snapshot(s)", 13 Help: "Remove one or more image(s)/volume(s)/snapshot(s)", 14 Examples: ` 15 $ scw rmi myimage 16 $ scw rmi mysnapshot 17 $ scw rmi myvolume 18 $ scw rmi $(scw images -q) 19 `, 20 } 21 22 func init() { 23 cmdRmi.Flag.BoolVar(&rmiHelp, []string{"h", "-help"}, false, "Print usage") 24 } 25 26 // Flags 27 var rmiHelp bool // -h, --help flag 28 29 func runRmi(cmd *Command, rawArgs []string) error { 30 if rmiHelp { 31 return cmd.PrintUsage() 32 } 33 if len(rawArgs) < 1 { 34 return cmd.PrintShortUsage() 35 } 36 37 args := commands.RmiArgs{ 38 Identifier: rawArgs, 39 } 40 ctx := cmd.GetContext(rawArgs) 41 return commands.RunRmi(ctx, args) 42 }