github.com/blend/go-sdk@v1.20220411.3/profanity/config.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package profanity
     9  
    10  // Config is the profanity rules parsing config.
    11  type Config struct {
    12  	Root      string     `yaml:"root"`
    13  	ExitFirst *bool      `yaml:"failFast"`
    14  	RulesFile string     `yaml:"rulesFile"`
    15  	Rules     GlobFilter `yaml:"rules"`
    16  	Files     GlobFilter `yaml:"files"`
    17  	Dirs      GlobFilter `yaml:"dirs"`
    18  	Verbose   *bool      `yaml:"verbose"`
    19  	Debug     *bool      `yaml:"debug"`
    20  }
    21  
    22  // RootOrDefault returns the starting path or a default.
    23  func (c Config) RootOrDefault() string {
    24  	if c.Root != "" {
    25  		return c.Root
    26  	}
    27  	return DefaultRoot
    28  }
    29  
    30  // RulesFileOrDefault returns the rules file or a default.
    31  func (c Config) RulesFileOrDefault() string {
    32  	if c.RulesFile != "" {
    33  		return c.RulesFile
    34  	}
    35  	return DefaultRulesFile
    36  }
    37  
    38  // ExitFirstOrDefault returns a value or a default.
    39  func (c Config) ExitFirstOrDefault() bool {
    40  	if c.ExitFirst != nil {
    41  		return *c.ExitFirst
    42  	}
    43  	return false
    44  }
    45  
    46  // VerboseOrDefault returns a value or a default.
    47  func (c Config) VerboseOrDefault() bool {
    48  	if c.Verbose != nil {
    49  		return *c.Verbose
    50  	}
    51  	return false
    52  }
    53  
    54  // DebugOrDefault returns a value or a default.
    55  func (c Config) DebugOrDefault() bool {
    56  	if c.Debug != nil {
    57  		return *c.Debug
    58  	}
    59  	return false
    60  }