1 Star 0 Fork 0

aspnmy / i18n4go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
quota.go 1.50 KB
一键复制 编辑 原始数据 按行查看 历史
dr.max 提交于 2014-06-12 16:58 . test_fixtures dependencies on CF CLI code
package quota
import ()
type showQuota struct {
ui terminal.UI
config configuration.Reader
quotaRepo api.QuotaRepository
}
func NewShowQuota(ui terminal.UI, config configuration.Reader, quotaRepo api.QuotaRepository) *showQuota {
return &showQuota{
ui: ui,
config: config,
quotaRepo: quotaRepo,
}
}
func (command *showQuota) Metadata() command_metadata.CommandMetadata {
return command_metadata.CommandMetadata{
Name: "quota",
Usage: "CF_NAME quota QUOTA",
Description: "Show quota info",
}
}
func (cmd *showQuota) GetRequirements(requirementsFactory requirements.Factory, context *cli.Context) ([]requirements.Requirement, error) {
if len(context.Args()) != 1 {
cmd.ui.FailWithUsage(context, "quotas")
}
return []requirements.Requirement{
requirementsFactory.NewLoginRequirement(),
}, nil
}
func (cmd *showQuota) Run(context *cli.Context) {
quotaName := context.Args()[0]
cmd.ui.Say("Getting quota %s info as %s...", quotaName, cmd.config.Username())
quota, err := cmd.quotaRepo.FindByName(quotaName)
if err != nil {
cmd.ui.Failed(err.Error())
}
cmd.ui.Ok()
table := terminal.NewTable(cmd.ui, []string{"", ""})
table.Add([]string{"Memory", formatters.ByteSize(quota.MemoryLimit * formatters.MEGABYTE)})
table.Add([]string{"Routes", fmt.Sprintf("%d", quota.RoutesLimit)})
table.Add([]string{"Services", fmt.Sprintf("%d", quota.ServicesLimit)})
table.Add([]string{"Paid service plans", formatters.Allowed(quota.NonBasicServicesAllowed)})
table.Print()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/Aodao/i18n4go.git
git@gitee.com:Aodao/i18n4go.git
Aodao
i18n4go
i18n4go
v0.2.6

搜索帮助

344bd9b3 5694891 D2dac590 5694891