本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/configuration/core_config.Reader类的典型用法代码示例。如果您正苦于以下问题:Golang Reader类的具体用法?Golang Reader怎么用?Golang Reader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Reader类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Init
func Init(config core_config.Reader) go_i18n.TranslateFunc {
sources := []string{
config.Locale(),
os.Getenv(lcAll),
os.Getenv(lang),
defaultLocale,
}
assetNames := resources.AssetNames()
for _, source := range sources {
if source == "" {
continue
}
for _, l := range language.Parse(source) {
if l.Tag == zhTW || l.Tag == zhHK {
l.Tag = zhHant
}
for _, assetName := range assetNames {
assetLocale := strings.ToLower(strings.Replace(path.Base(assetName), underscore, hyphen, -1))
if strings.HasPrefix(assetLocale, l.Tag) {
assetBytes, err := resources.Asset(assetName)
if err != nil {
panic(fmt.Sprintf("Could not load asset '%s': %s", assetName, err.Error()))
}
err = go_i18n.ParseTranslationFileBytes(assetName, assetBytes)
if err != nil {
panic(fmt.Sprintf("Could not load translations '%s': %s", assetName, err.Error()))
}
T, err := go_i18n.Tfunc(source)
if err == nil {
return T
}
}
}
}
}
panic("Unable to find suitable translation")
}
开发者ID:vframbach,项目名称:cli,代码行数:44,代码来源:i18n.go
示例2: Init
func Init(config core_config.Reader) go_i18n.TranslateFunc {
loadAsset("cf/i18n/resources/" + defaultLocale + resourceSuffix)
defaultTfunc := go_i18n.MustTfunc(defaultLocale)
assetNames := resources.AssetNames()
sources := []string{
config.Locale(),
os.Getenv(lcAll),
os.Getenv(lang),
}
for _, source := range sources {
if source == "" {
continue
}
for _, l := range language.Parse(source) {
if l.Tag == zhTW || l.Tag == zhHK {
l.Tag = zhHant
}
for _, assetName := range assetNames {
assetLocale := strings.ToLower(strings.Replace(path.Base(assetName), underscore, hyphen, -1))
if strings.HasPrefix(assetLocale, l.Tag) {
loadAsset(assetName)
t := go_i18n.MustTfunc(source)
return func(translationID string, args ...interface{}) string {
if translated := t(translationID, args...); translated != translationID {
return translated
}
return defaultTfunc(translationID, args...)
}
}
}
}
}
return defaultTfunc
}
开发者ID:mandarjog,项目名称:cli,代码行数:43,代码来源:i18n.go
示例3: NotifyUpdateIfNeeded
func (ui *terminalUI) NotifyUpdateIfNeeded(config core_config.Reader) {
if !config.IsMinCliVersion(cf.Version) {
ui.Say("")
ui.Say(T("Cloud Foundry API version {{.ApiVer}} requires CLI version {{.CliMin}}. You are currently on version {{.CliVer}}. To upgrade your CLI, please visit: https://github.com/cloudfoundry/cli#downloads",
map[string]interface{}{
"ApiVer": config.ApiVersion(),
"CliMin": config.MinCliVersion(),
"CliVer": cf.Version,
}))
}
}
开发者ID:seetharamireddy540,项目名称:cli,代码行数:11,代码来源:ui.go
示例4: ShowConfiguration
func (ui *terminalUI) ShowConfiguration(config core_config.Reader) {
table := NewTable(ui, []string{"", ""})
if config.HasAPIEndpoint() {
table.Add(
T("API endpoint:"),
T("{{.ApiEndpoint}} (API version: {{.ApiVersionString}})",
map[string]interface{}{
"ApiEndpoint": EntityNameColor(config.ApiEndpoint()),
"ApiVersionString": EntityNameColor(config.ApiVersion()),
}),
)
}
if !config.IsLoggedIn() {
table.Print()
ui.Say(NotLoggedInText())
return
} else {
table.Add(
T("User:"),
EntityNameColor(config.UserEmail()),
)
}
if !config.HasOrganization() && !config.HasSpace() {
table.Print()
command := fmt.Sprintf("%s target -o ORG -s SPACE", cf.Name())
ui.Say(T("No org or space targeted, use '{{.CFTargetCommand}}'",
map[string]interface{}{
"CFTargetCommand": CommandColor(command),
}))
return
}
if config.HasOrganization() {
table.Add(
T("Org:"),
EntityNameColor(config.OrganizationFields().Name),
)
} else {
command := fmt.Sprintf("%s target -o Org", cf.Name())
table.Add(
T("Org:"),
T("No org targeted, use '{{.CFTargetCommand}}'",
map[string]interface{}{
"CFTargetCommand": CommandColor(command),
}),
)
}
if config.HasSpace() {
table.Add(
T("Space:"),
EntityNameColor(config.SpaceFields().Name),
)
} else {
command := fmt.Sprintf("%s target -s SPACE", cf.Name())
table.Add(
T("Space:"),
T("No space targeted, use '{{.CFTargetCommand}}'", map[string]interface{}{"CFTargetCommand": CommandColor(command)}),
)
}
table.Print()
}
开发者ID:raghulsid,项目名称:cli,代码行数:66,代码来源:ui.go
示例5: NotifyUpdateIfNeeded
func (ui *FakeUI) NotifyUpdateIfNeeded(config core_config.Reader) {
if !config.IsMinCliVersion(cf.Version) {
ui.Say("Cloud Foundry API version {{.ApiVer}} requires CLI version " + config.MinCliVersion() + " You are currently on version {{.CliVer}}. To upgrade your CLI, please visit: https://github.com/cloudfoundry/cli#downloads")
}
}
开发者ID:vframbach,项目名称:cli,代码行数:5,代码来源:ui.go
注:本文中的github.com/cloudfoundry/cli/cf/configuration/core_config.Reader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论