github.com/ilhicas/nomad@v0.11.8/command/license_get.go (about) 1 package command 2 3 import ( 4 "fmt" 5 ) 6 7 type LicenseGetCommand struct { 8 Meta 9 } 10 11 func (c *LicenseGetCommand) Help() string { 12 helpText := ` 13 Usage: nomad license get [options] 14 15 Gets a new license in Servers and Clients 16 General Options: 17 18 ` + generalOptionsUsage() 19 20 return helpText 21 } 22 23 func (c *LicenseGetCommand) Synopsis() string { 24 return "Install a new Nomad Enterprise License" 25 } 26 27 func (c *LicenseGetCommand) Name() string { return "license get" } 28 29 func (c *LicenseGetCommand) Run(args []string) int { 30 flags := c.Meta.FlagSet(c.Name(), FlagSetClient) 31 flags.Usage = func() { c.Ui.Output(c.Help()) } 32 33 if err := flags.Parse(args); err != nil { 34 c.Ui.Error(fmt.Sprintf("Error parsing flags: %s", err)) 35 return 1 36 } 37 38 client, err := c.Meta.Client() 39 if err != nil { 40 c.Ui.Error(fmt.Sprintf("Error initializing client: %s", err)) 41 return 1 42 } 43 44 resp, _, err := client.Operator().LicenseGet(nil) 45 if err != nil { 46 c.Ui.Error(fmt.Sprintf("Error getting license: %v", err)) 47 return 1 48 } 49 50 return OutputLicenseReply(c.Ui, resp) 51 }