github.com/orange-cloudfoundry/cli@v7.1.0+incompatible/command/v7/org_quotas_command.go (about)

     1  package v7
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/command/v7/shared"
     5  	"code.cloudfoundry.org/cli/resources"
     6  )
     7  
     8  type OrgQuotasCommand struct {
     9  	BaseCommand
    10  
    11  	usage           interface{} `usage:"CF_NAME org-quotas"`
    12  	relatedCommands interface{} `related_commands:"org-quota"`
    13  }
    14  
    15  func (cmd OrgQuotasCommand) Execute(args []string) error {
    16  	err := cmd.SharedActor.CheckTarget(false, false)
    17  	if err != nil {
    18  		return err
    19  	}
    20  
    21  	user, err := cmd.Config.CurrentUser()
    22  	if err != nil {
    23  		return err
    24  	}
    25  
    26  	cmd.UI.DisplayTextWithFlavor("Getting org quotas as {{.Username}}...", map[string]interface{}{
    27  		"Username": user.Name,
    28  	})
    29  	cmd.UI.DisplayNewline()
    30  
    31  	orgQuotas, warnings, err := cmd.Actor.GetOrganizationQuotas()
    32  	cmd.UI.DisplayWarnings(warnings)
    33  	if err != nil {
    34  		return err
    35  	}
    36  
    37  	var quotas []resources.Quota
    38  	for _, orgQuota := range orgQuotas {
    39  		quotas = append(quotas, resources.Quota(orgQuota.Quota))
    40  	}
    41  
    42  	quotaDisplayer := shared.NewQuotaDisplayer(cmd.UI)
    43  	quotaDisplayer.DisplayQuotasTable(quotas, "No organization quotas found.")
    44  
    45  	return nil
    46  }