github.com/niteshexa/cloudfoundry_cli@v7.1.0+incompatible/command/v7/org_quota_command.go (about)

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