1 Star 0 Fork 0

aspnmy/i18n4go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
quotas.go 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
dr.max 提交于 2014-06-12 16:58 . test_fixtures dependencies on CF CLI code
package quota
import ()
type ListQuotas struct {
ui terminal.UI
config configuration.Reader
quotaRepo api.QuotaRepository
}
func NewListQuotas(ui terminal.UI, config configuration.Reader, quotaRepo api.QuotaRepository) (cmd *ListQuotas) {
cmd = new(ListQuotas)
cmd.ui = ui
cmd.config = config
cmd.quotaRepo = quotaRepo
return
}
func (command *ListQuotas) Metadata() command_metadata.CommandMetadata {
return command_metadata.CommandMetadata{
Name: "quotas",
Description: "List available usage quotas",
Usage: "CF_NAME quotas",
}
}
func (cmd *ListQuotas) GetRequirements(requirementsFactory requirements.Factory, c *cli.Context) (reqs []requirements.Requirement, err error) {
reqs = []requirements.Requirement{
requirementsFactory.NewLoginRequirement(),
}
return
}
func (cmd *ListQuotas) Run(c *cli.Context) {
cmd.ui.Say("Getting quotas as %s...", terminal.EntityNameColor(cmd.config.Username()))
quotas, apiErr := cmd.quotaRepo.FindAll()
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
cmd.ui.Say("")
table := terminal.NewTable(cmd.ui, []string{"name", "memory limit", "routes", "service instances", "paid service plans"})
for _, quota := range quotas {
table.Add([]string{
quota.Name,
formatters.ByteSize(quota.MemoryLimit * formatters.MEGABYTE),
fmt.Sprintf("%d", quota.RoutesLimit),
fmt.Sprintf("%d", quota.ServicesLimit),
formatters.Allowed(quota.NonBasicServicesAllowed),
})
}
table.Print()
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/Aodao/i18n4go.git
git@gitee.com:Aodao/i18n4go.git
Aodao
i18n4go
i18n4go
v0.2.1

搜索帮助

0d507c66 1850385 C8b1a773 1850385