github.com/djenriquez/nomad-1@v0.8.1/command/quota_delete.go (about) 1 package command 2 3 import ( 4 "fmt" 5 "strings" 6 7 "github.com/posener/complete" 8 ) 9 10 type QuotaDeleteCommand struct { 11 Meta 12 } 13 14 func (c *QuotaDeleteCommand) Help() string { 15 helpText := ` 16 Usage: nomad quota delete [options] <quota> 17 18 Delete is used to delete an existing quota specification. 19 20 General Options: 21 22 ` + generalOptionsUsage() 23 24 return strings.TrimSpace(helpText) 25 } 26 27 func (c *QuotaDeleteCommand) AutocompleteFlags() complete.Flags { 28 return c.Meta.AutocompleteFlags(FlagSetClient) 29 } 30 31 func (c *QuotaDeleteCommand) AutocompleteArgs() complete.Predictor { 32 return QuotaPredictor(c.Meta.Client) 33 } 34 35 func (c *QuotaDeleteCommand) Synopsis() string { 36 return "Delete a quota specification" 37 } 38 39 func (c *QuotaDeleteCommand) Run(args []string) int { 40 flags := c.Meta.FlagSet("quota delete", FlagSetClient) 41 flags.Usage = func() { c.Ui.Output(c.Help()) } 42 43 if err := flags.Parse(args); err != nil { 44 return 1 45 } 46 47 // Check that we got one argument 48 args = flags.Args() 49 if l := len(args); l != 1 { 50 c.Ui.Error(c.Help()) 51 return 1 52 } 53 54 name := args[0] 55 56 // Get the HTTP client 57 client, err := c.Meta.Client() 58 if err != nil { 59 c.Ui.Error(fmt.Sprintf("Error initializing client: %s", err)) 60 return 1 61 } 62 63 _, err = client.Quotas().Delete(name, nil) 64 if err != nil { 65 c.Ui.Error(fmt.Sprintf("Error deleting quota: %s", err)) 66 return 1 67 } 68 69 c.Ui.Output(fmt.Sprintf("Successfully deleted quota %q!", name)) 70 return 0 71 }