Beispiel #1
0
// NewGlobalOptions constructor
func NewGlobalOptions(c util.Settings, e *util.Environment) (*GlobalOptions, error) {
	baseURL, _ := c.GlobalString("base-url", DEFAULT_BASE_URL)
	baseURL = strings.TrimRight(baseURL, "/")
	debug, _ := c.GlobalBool("debug")
	journal, _ := c.GlobalBool("journal")
	verbose, _ := c.GlobalBool("verbose")
	// TODO(termie): switch negative flag
	showColors, _ := c.GlobalBool("no-colors")
	showColors = !showColors

	authTokenStore, _ := c.GlobalString("auth-token-store")
	authTokenStore = util.ExpandHomePath(authTokenStore, e.Get("HOME"))
	authToken := guessAuthToken(c, e, authTokenStore)

	// If debug is true, than force verbose and do not use colors.
	if debug {
		verbose = true
		showColors = false
	}

	return &GlobalOptions{
		BaseURL:    baseURL,
		Debug:      debug,
		Journal:    journal,
		Verbose:    verbose,
		ShowColors: showColors,

		AuthToken:      authToken,
		AuthTokenStore: authTokenStore,
	}, nil
}
Beispiel #2
0
// IgnoreFilePath return the absolute path of the ignore file
func (o *PipelineOptions) IgnoreFilePath() string {
	expandedIgnoreFile := util.ExpandHomePath(o.IgnoreFile, o.HostEnv.Get("HOME"))

	if filepath.IsAbs(expandedIgnoreFile) {
		return expandedIgnoreFile
	} else {
		return path.Join(o.ProjectPath, o.IgnoreFile)
	}
}