本文整理汇总了Golang中github.com/bitrise-io/go-utils/colorstring.Green函数的典型用法代码示例。如果您正苦于以下问题:Golang Green函数的具体用法?Golang Green怎么用?Golang Green使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Green函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: printFinishShare
func printFinishShare() {
fmt.Println()
log.Info(" * " + colorstring.Green("[OK] ") + "Yeah!! You rock!!")
fmt.Println()
fmt.Println(" " + GuideTextForFinish())
fmt.Println()
msg := ` You can create a pull request in your forked StepLib repository,
if you used the main StepLib repository then your repository's url looks like: ` + `
` + colorstring.Green("https://github.com/[your-username]/bitrise-steplib") + `
On GitHub you can find a ` + colorstring.Green("'Compare & pull request'") + ` button, in the ` + colorstring.Green("'Your recently pushed branches:'") + ` section,
which will bring you to the 'Open a pull request' page, where you can review and create your Pull Request.
`
fmt.Println(msg)
}
示例2: InstallWithAptGetIfNeeded
// InstallWithAptGetIfNeeded ...
func InstallWithAptGetIfNeeded(tool string, isCIMode bool) error {
if out, err := cmdex.RunCommandAndReturnCombinedStdoutAndStderr("which", tool); err != nil {
if err.Error() == "exit status 1" && out == "" {
// Tool isn't installed -- install it...
if !isCIMode {
log.Infof("This step requires %s, which is not installed", tool)
allow, err := goinp.AskForBool("Would you like to install (" + tool + ") with brew ? [yes/no]")
if err != nil {
return err
}
if !allow {
return errors.New("(" + tool + ") is required for step")
}
}
log.Infof("(%s) isn't installed, installing...", tool)
if out, err := cmdex.RunCommandAndReturnCombinedStdoutAndStderr("sudo", "apt-get", "-y", "install", tool); err != nil {
log.Errorf("sudo apt-get -y install %s failed -- out: (%s) err: (%s)", tool, out, err)
return err
}
log.Infof(" * "+colorstring.Green("[OK]")+" %s installed", tool)
} else {
// which failed
log.Errorf("which (%s) failed -- out: (%s) err: (%s)", tool, out, err)
return err
}
} else if out != "" {
// already installed
} else {
log.Warnf("which (%s) -- out (%s)", tool, out)
}
return nil
}
示例3: pluginList
func pluginList(c *cli.Context) {
pluginMap, err := plugins.ListPlugins()
if err != nil {
log.Fatalf("Failed to list plugins, err: %s", err)
}
pluginNames := []string{}
for _, plugins := range pluginMap {
for _, plugin := range plugins {
pluginNames = append(pluginNames, plugin.PrintableName())
}
}
sort.Strings(pluginNames)
if len(pluginNames) > 0 {
fmt.Println("")
for _, name := range pluginNames {
fmt.Printf(" ⚡️ %s\n", colorstring.Green(name))
}
fmt.Println("")
} else {
fmt.Println("")
fmt.Println("No installed plugin found")
fmt.Println("")
}
}
示例4: doSetupToolkits
func doSetupToolkits() error {
log.Infoln("Checking Bitrise Toolkits...")
coreToolkits := toolkits.AllSupportedToolkits()
for _, aCoreTK := range coreToolkits {
toolkitName := aCoreTK.ToolkitName()
isInstallRequired, checkResult, err := aCoreTK.Check()
if err != nil {
return fmt.Errorf("Failed to perform toolkit check (%s), error: %s", toolkitName, err)
}
if isInstallRequired {
log.Infoln("No installed/suitable '" + toolkitName + "' found, installing toolkit ...")
if err := aCoreTK.Install(); err != nil {
return fmt.Errorf("Failed to install toolkit (%s), error: %s", toolkitName, err)
}
isInstallRequired, checkResult, err = aCoreTK.Check()
if err != nil {
return fmt.Errorf("Failed to perform toolkit check (%s), error: %s", toolkitName, err)
}
}
if isInstallRequired {
return fmt.Errorf("Toolkit (%s) still reports that it isn't (properly) installed", toolkitName)
}
log.Infoln(" * "+colorstring.Green("[OK]")+" "+toolkitName+" :", checkResult.Path)
log.Infoln(" version :", checkResult.Version)
}
return nil
}
示例5: printFinishCreate
func printFinishCreate(share ShareModel, stepDirInSteplib string, toolMode bool) {
fmt.Println()
log.Infof(" * "+colorstring.Green("[OK]")+" Your Step (%s) (%s) added to local StepLib (%s).", share.StepID, share.StepTag, stepDirInSteplib)
log.Infoln(" * You can find your Step's step.yml at: " + colorstring.Greenf("%s/step.yml", stepDirInSteplib))
fmt.Println()
fmt.Println(" " + GuideTextForShareFinish(toolMode))
}
示例6: checkIsBitriseToolInstalled
func checkIsBitriseToolInstalled(toolname, minVersion string, isInstall bool) error {
doInstall := func() error {
installCmdLines := []string{
"curl -fL https://github.com/bitrise-io/" + toolname + "/releases/download/" + minVersion + "/" + toolname + "-$(uname -s)-$(uname -m) > /usr/local/bin/" + toolname,
"chmod +x /usr/local/bin/" + toolname,
}
officialGithub := "https://github.com/bitrise-io/" + toolname
fmt.Println()
log.Warnln("No supported " + toolname + " version found.")
log.Infoln("You can find more information about "+toolname+" on it's official GitHub page:", officialGithub)
fmt.Println()
// Install
log.Infoln("Installing...")
fmt.Println(strings.Join(installCmdLines, "\n"))
if err := cmdex.RunBashCommandLines(installCmdLines); err != nil {
return err
}
// check again
return checkIsBitriseToolInstalled(toolname, minVersion, false)
}
// check whether installed
progInstallPth, err := CheckProgramInstalledPath(toolname)
if err != nil {
if !isInstall {
return err
}
return doInstall()
}
verStr, err := cmdex.RunCommandAndReturnStdout(toolname, "-version")
if err != nil {
log.Infoln("")
return errors.New("Failed to get version")
}
// version check
isVersionOk, err := versions.IsVersionGreaterOrEqual(verStr, minVersion)
if err != nil {
log.Error("Failed to validate installed version")
return err
}
if !isVersionOk {
log.Warn("Installed "+toolname+" found, but not a supported version: ", verStr)
if !isInstall {
return errors.New("Failed to install required version.")
}
log.Warn("Updating...")
return doInstall()
}
log.Infoln(" * "+colorstring.Green("[OK]")+" "+toolname+" :", progInstallPth)
log.Infoln(" version :", verStr)
return nil
}
示例7: GuideTextForStart
// GuideTextForStart ...
func GuideTextForStart() string {
guide := colorstring.Blue("Fork the StepLib repository") + " you want to share your Step in.\n" +
` You can find the main ("official") StepLib repository at: ` + colorstring.Green("https://github.com/bitrise-io/bitrise-steplib") + `
` + colorstring.Yellow("Note") + `: You can use any StepLib repository you like,
the StepLib system is decentralized, you don't have to work with the main StepLib repository
if you don't want to. Feel free to maintain and use your own (or your team's) Step Library.
`
return guide
}
示例8: InstallWithAptGetIfNeeded
// InstallWithAptGetIfNeeded ...
func InstallWithAptGetIfNeeded(aptGetDep stepmanModels.AptGetDepModel, isCIMode bool) error {
isDepInstalled := false
// First do a "which", to see if the binary is available.
// Can be available from another source, not just from brew,
// e.g. it's common to use NVM or similar to install and manage the Node.js version.
{
if out, err := cmdex.RunCommandAndReturnCombinedStdoutAndStderr("which", aptGetDep.GetBinaryName()); err != nil {
if err.Error() == "exit status 1" && out == "" {
isDepInstalled = false
} else {
// unexpected `which` error
return fmt.Errorf("which (%s) failed -- out: (%s) err: (%s)", aptGetDep.Name, out, err)
}
} else if out != "" {
isDepInstalled = true
} else {
// no error but which's output was empty
return fmt.Errorf("which (%s) failed -- no error (exit code 0) but output was empty", aptGetDep.Name)
}
}
// then do a package manager specific lookup
{
if !isDepInstalled {
// which did not find the binary, also check in brew,
// whether the package is installed
isDepInstalled = checkIfAptPackageInstalled(aptGetDep.Name)
}
}
if !isDepInstalled {
// Tool isn't installed -- install it...
if !isCIMode {
log.Infof(`This step requires "%s" to be available, but it is not installed.`, aptGetDep.GetBinaryName())
allow, err := goinp.AskForBoolWithDefault(`Would you like to install the "`+aptGetDep.Name+`" package with apt-get?`, true)
if err != nil {
return err
}
if !allow {
return errors.New("(" + aptGetDep.Name + ") is required for step")
}
}
log.Infof("(%s) isn't installed, installing...", aptGetDep.Name)
if cmdOut, err := cmdex.RunCommandAndReturnCombinedStdoutAndStderr("sudo", "apt-get", "-y", "install", aptGetDep.Name); err != nil {
log.Errorf("sudo apt-get -y install %s failed -- out: (%s) err: (%s)", aptGetDep.Name, cmdOut, err)
return err
}
log.Infof(" * "+colorstring.Green("[OK]")+" %s installed", aptGetDep.Name)
}
return nil
}
示例9: share
func share(c *cli.Context) error {
toolMode := c.Bool(ToolMode)
guide := `
Do you want to ` + colorstring.Green("share ") + colorstring.Yellow("your ") + colorstring.Magenta("own ") + colorstring.Blue("Step") + ` with the world? Awesome!!
To get started you can find a template Step repository at: ` + colorstring.Green("https://github.com/bitrise-steplib/step-template") + `
Once you have your Step in a ` + colorstring.Yellow("public git repository") + ` you can share it with others.
To share your Step just follow these steps (pun intended ;) :
1. ` + GuideTextForStart() + `
2. ` + GuideTextForShareStart(toolMode) + `
3. ` + GuideTextForShareCreate(toolMode) + `
4. ` + GuideTextForAudit(toolMode) + `
5. ` + GuideTextForShareFinish(toolMode) + `
6. ` + GuideTextForFinish()
fmt.Println(guide)
return nil
}
示例10: printRawEnvInfo
func printRawEnvInfo(env models.EnvInfoModel) {
if env.DefaultValue != "" {
fmt.Printf("- %s: %s\n", colorstring.Green(env.Key), env.DefaultValue)
} else {
fmt.Printf("- %s\n", colorstring.Green(env.Key))
}
fmt.Printf(" %s: %v\n", colorstring.Green("is expand"), env.IsExpand)
if len(env.ValueOptions) > 0 {
fmt.Printf(" %s:\n", colorstring.Green("value options"))
for _, option := range env.ValueOptions {
fmt.Printf(" - %s\n", option)
}
}
if env.Description != "" {
fmt.Printf(" %s:\n", colorstring.Green("description"))
fmt.Printf(" %s\n", env.Description)
}
}
示例11: GuideTextForShareStart
// GuideTextForShareStart ...
func GuideTextForShareStart(toolMode bool) string {
name := "stepman"
if toolMode {
name = "bitrise"
}
guide := "Call " + colorstring.Blue("'"+name+" share start -c STEPLIB_REPO_FORK_GIT_URL'") + ", with the " + colorstring.Yellow("git clone url") + " of " + colorstring.Yellow("your forked StepLib repository") + ".\n" +
` This will prepare your forked StepLib locally for sharing.
For example, if you want to share your Step in the main StepLib repository you should call:
` + colorstring.Green(""+name+" share start -c https://github.com/[your-username]/bitrise-steplib.git") + `
`
return guide
}
示例12: InstallWithBrewIfNeeded
// InstallWithBrewIfNeeded ...
func InstallWithBrewIfNeeded(brewDep stepmanModels.BrewDepModel, isCIMode bool) error {
isDepInstalled := false
// First do a "which", to see if the binary is available.
// Can be available from another source, not just from brew,
// e.g. it's common to use NVM or similar to install and manage the Node.js version.
if out, err := cmdex.RunCommandAndReturnCombinedStdoutAndStderr("which", brewDep.GetBinaryName()); err != nil {
if err.Error() == "exit status 1" && out == "" {
isDepInstalled = false
} else {
// unexpected `which` error
return fmt.Errorf("which (%s) failed -- out: (%s) err: (%s)", brewDep.Name, out, err)
}
} else if out != "" {
isDepInstalled = true
} else {
// no error but which's output was empty
return fmt.Errorf("which (%s) failed -- no error (exit code 0) but output was empty", brewDep.Name)
}
if !isDepInstalled {
// which did not find the binary, also check in brew,
// whether the package is installed
isDepInstalled = checkIfBrewPackageInstalled(brewDep.Name)
}
if !isDepInstalled {
// Tool isn't installed -- install it...
if !isCIMode {
log.Infof("This step requires %s, which is not installed", brewDep.Name)
allow, err := goinp.AskForBool("Would you like to install (" + brewDep.Name + ") with brew?")
if err != nil {
return err
}
if !allow {
return errors.New("(" + brewDep.Name + ") is required for step")
}
}
log.Infof("(%s) isn't installed, installing...", brewDep.Name)
if out, err := cmdex.RunCommandAndReturnCombinedStdoutAndStderr("brew", "install", brewDep.Name); err != nil {
log.Errorf("brew install %s failed -- out: (%s) err: (%s)", brewDep.Name, out, err)
return err
}
log.Infof(" * "+colorstring.Green("[OK]")+" %s installed", brewDep.Name)
}
return nil
}
示例13: GuideTextForShareCreate
// GuideTextForShareCreate ...
func GuideTextForShareCreate(toolMode bool) string {
name := "stepman"
if toolMode {
name = "bitrise"
}
guide := "Next, call " + colorstring.Blue("'"+name+" share create --tag STEP_VERSION_TAG --git STEP_GIT_URI --stepid STEP_ID'") + `,
to add your Step to your forked StepLib repository (locally).
This will copy the required step.yml file from your Step's repository.
This is all what's required to add your step (or a new version) to a StepLib.
` + colorstring.Yellow("Important") + `: You have to add the (version) tag to your Step's repository before you would call this!
You can do that at: https://github.com/[your-username]/[step-repository]/tags
An example call:
` + colorstring.Green(""+name+" share create --tag 1.0.0 --git https://github.com/[your-username]/[step-repository].git --stepid my-awesome-step") + `
` + colorstring.Yellow("Note") + `: You'll still be able to modify the step.yml in the StepLib after this.
`
return guide
}
示例14: PrintInstalledXcodeInfos
// PrintInstalledXcodeInfos ...
func PrintInstalledXcodeInfos() error {
xcodeSelectPth, err := cmdex.RunCommandAndReturnStdout("xcode-select", "--print-path")
if err != nil {
xcodeSelectPth = "xcode-select --print-path failed to detect the location of activate Xcode Command Line Tools path"
}
progInstallPth, err := utils.CheckProgramInstalledPath("xcodebuild")
if err != nil {
return errors.New("xcodebuild is not installed")
}
isFullXcodeAvailable := false
verStr, err := cmdex.RunCommandAndReturnCombinedStdoutAndStderr("xcodebuild", "-version")
if err != nil {
// No full Xcode available, only the Command Line Tools
// verStr is something like "xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance"
isFullXcodeAvailable = false
} else {
// version OK - full Xcode available
// we'll just format it a bit to fit into one line
isFullXcodeAvailable = true
verStr = strings.Join(strings.Split(verStr, "\n"), " | ")
}
log.Infoln(" * "+colorstring.Green("[OK]")+" xcodebuild path :", progInstallPth)
if !isFullXcodeAvailable {
log.Infoln(" version (xcodebuild) :", colorstring.Yellowf("%s", verStr))
} else {
log.Infoln(" version (xcodebuild) :", verStr)
}
log.Infoln(" active Xcode (Command Line Tools) path (xcode-select --print-path) :", xcodeSelectPth)
if !isFullXcodeAvailable {
log.Warn(colorstring.Yellowf("%s", "No Xcode found, only the Xcode Command Line Tools are available!"))
log.Warn(colorstring.Yellowf("%s", "Full Xcode is required to build, test and archive iOS apps!"))
}
return nil
}
示例15: InstallWithBrewIfNeeded
// InstallWithBrewIfNeeded ...
func InstallWithBrewIfNeeded(tool string, isCIMode bool) error {
if err := checkWithBrewProgramInstalled(tool); err != nil {
if !isCIMode {
log.Infof("This step requires %s, which is not installed", tool)
allow, err := goinp.AskForBool("Would you like to install (" + tool + ") with brew ? [yes/no]")
if err != nil {
return err
}
if !allow {
return errors.New("(" + tool + ") is required for step")
}
}
log.Infof("(%s) isn't installed, installing...", tool)
if out, err := cmdex.RunCommandAndReturnCombinedStdoutAndStderr("brew", "install", tool); err != nil {
log.Errorf("brew install %s failed -- out: (%s) err: (%s)", tool, out, err)
return err
}
log.Infof(" * "+colorstring.Green("[OK]")+" %s installed", tool)
return nil
}
return nil
}