本文整理汇总了Golang中v/io/jiri/profiles.Target.CommandLineEnv方法的典型用法代码示例。如果您正苦于以下问题:Golang Target.CommandLineEnv方法的具体用法?Golang Target.CommandLineEnv怎么用?Golang Target.CommandLineEnv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类v/io/jiri/profiles.Target
的用法示例。
在下文中一共展示了Target.CommandLineEnv方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: fmtInfo
func fmtInfo(jirix *jiri.X, infoFmt string, rd *profilesreader.Reader, profile *profiles.Profile, target *profiles.Target) (string, error) {
// Populate an instance listInfo
info := &listInfo{}
name := profile.Name()
installer, _ := profiles.SplitProfileName(name)
info.SchemaVersion = rd.SchemaVersion()
info.DBPath = rd.Path()
if target != nil {
info.Target.InstallationDir = jiri.NewRelPath(target.InstallationDir).Abs(jirix)
info.Target.CommandLineEnv = target.CommandLineEnv().Vars
info.Target.Env = target.Env.Vars
clenv := ""
if len(info.Target.CommandLineEnv) > 0 {
clenv = fmt.Sprintf(" --env=\"%s\" ", strings.Join(info.Target.CommandLineEnv, ","))
}
if installer != "" {
info.Target.Command = fmt.Sprintf("jiri profile install --target=%s %s%s", target, clenv, name)
} else {
// TODO(cnicolaou): remove this when the transition is complete.
info.Target.Command = fmt.Sprintf("jiri v23-profile install --target=%s %s%s", target, clenv, name)
}
}
if profile != nil {
rp := jiri.NewRelPath(profile.Root())
info.Profile.Root = rp.Abs(jirix)
info.Profile.Name = name
info.Profile.Installer = installer
info.Profile.DBPath = info.DBPath
if installer != "" {
info.Profile.DBPath = filepath.Join(info.DBPath, installer)
}
}
// Use a template to print out any field in our instance of listInfo.
tmpl, err := template.New("list").Parse("{{ ." + infoFmt + "}}")
if err != nil {
return "", err
}
out := &bytes.Buffer{}
if err = tmpl.Execute(out, info); err != nil {
return "", fmt.Errorf("please specify a supported field:\n%s", infoUsage())
}
return out.String(), nil
}