github.com/MealCraft/glide@v0.13.4/action/project_info.go (about)

     1  package action
     2  
     3  import (
     4  	"bytes"
     5  
     6  	"github.com/Masterminds/glide/msg"
     7  )
     8  
     9  // Info prints information about a project based on a passed in format.
    10  func Info(format string) {
    11  	conf := EnsureConfig()
    12  	var buffer bytes.Buffer
    13  	varInit := false
    14  	for _, varfmt := range format {
    15  		if varInit {
    16  			switch varfmt {
    17  			case 'n':
    18  				buffer.WriteString(conf.Name)
    19  			case 'd':
    20  				buffer.WriteString(conf.Description)
    21  			case 'h':
    22  				buffer.WriteString(conf.Home)
    23  			case 'l':
    24  				buffer.WriteString(conf.License)
    25  			default:
    26  				msg.Die("Invalid format %s", string(varfmt))
    27  			}
    28  		} else {
    29  			switch varfmt {
    30  			case '%':
    31  				varInit = true
    32  				continue
    33  			default:
    34  				buffer.WriteString(string(varfmt))
    35  			}
    36  		}
    37  		varInit = false
    38  	}
    39  	msg.Puts(buffer.String())
    40  }