| 1 | package configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/ |
| 2 | |
| 3 | import ( |
| 4 | "strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/" |
| 5 | "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/" |
| 6 | ) |
| 7 | |
| 8 | // An Environment adds additional behavior to a Fetcher, such a type conversion, |
| 9 | // and default values. |
| 10 | // |
| 11 | // `Environment`s are the primary way to communicate with various configuration |
| 12 | // sources, such as the OS environment variables, the `.gitconfig`, and even |
| 13 | // `map[string]string`s. |
| 14 | type Environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment# interface { |
| 15 | // Get is shorthand for calling `e.Fetcher.Get(key)`. |
| 16 | Getscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment#Get.(key string) (val string, ok bool) |
| 17 | |
| 18 | // Get is shorthand for calling `e.Fetcher.GetAll(key)`. |
| 19 | GetAllscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment#GetAll.(key string) (vals []string) |
| 20 | |
| 21 | // Bool returns the boolean state associated with a given key, or the |
| 22 | // value "def", if no value was associated. |
| 23 | // |
| 24 | // The "boolean state associated with a given key" is defined as the |
| 25 | // case-insensitive string comparison with the following: |
| 26 | // |
| 27 | // 1) true if... |
| 28 | // "true", "1", "on", "yes", or "t" |
| 29 | // 2) false if... |
| 30 | // "false", "0", "off", "no", "f", or otherwise. |
| 31 | Boolscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment#Bool.(key string, def bool) (val bool) |
| 32 | |
| 33 | // Int returns the int value associated with a given key, or the value |
| 34 | // "def", if no value was associated. |
| 35 | // |
| 36 | // To convert from a the string value attached to a given key, |
| 37 | // `strconv.Atoi(val)` is called. If `Atoi` returned a non-nil error, |
| 38 | // then the value "def" will be returned instead. |
| 39 | // |
| 40 | // Otherwise, if the value was converted `string -> int` successfully, |
| 41 | // then it will be returned wholesale. |
| 42 | Intscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment#Int.(key string, def int) (val int) |
| 43 | |
| 44 | // Int64 returns the int64 value associated with a given key, or the value |
| 45 | // "def", if no value was associated. |
| 46 | // |
| 47 | // To convert from the string value attached to a given key, |
| 48 | // `strconv.ParseInt(val, 10, 64)` is called. If `ParseInt` returned a |
| 49 | // non-nil error, then the value "def" will be returned instead. |
| 50 | // |
| 51 | // Otherwise, if the value was converted `string -> int64` successfully, |
| 52 | // then it will be returned wholesale. |
| 53 | Int64scip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment#Int64.(key string, def int64) (val int64) |
| 54 | |
| 55 | // All returns a copy of all the key/value pairs for the current |
| 56 | // environment. |
| 57 | Allscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment#All.() map[string][]string |
| 58 | } |
| 59 | |
| 60 | type environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment# struct { |
| 61 | // Fetcher is the `environment`'s source of data. |
| 62 | Fetcherscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#Fetcher. Fetcherscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Fetcher# |
| 63 | } |
| 64 | |
| 65 | // EnvironmentOf creates a new `Environment` initialized with the givne |
| 66 | // `Fetcher`, "f". |
| 67 | func EnvironmentOfscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/EnvironmentOf().(f Fetcherscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Fetcher#) Environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment# { |
| 68 | return &environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#{f} |
| 69 | } |
| 70 | |
| 71 | func (e *environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#) Getscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#Get().(key string) (val string, ok bool) { |
| 72 | return e.Fetcherscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#Fetcher..Getscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Fetcher#Get.(key) |
| 73 | } |
| 74 | |
| 75 | func (e *environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#) GetAllscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#GetAll().(key string) []string { |
| 76 | return e.Fetcherscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#Fetcher..GetAllscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Fetcher#GetAll.(key) |
| 77 | } |
| 78 | |
| 79 | func (e *environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#) Boolscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#Bool().(key string, def bool) bool { |
| 80 | s, _ := e.Fetcherscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#Fetcher..Getscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Fetcher#Get.(key) |
| 81 | return Boolscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Bool().(s, def) |
| 82 | } |
| 83 | |
| 84 | func (e *environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#) Intscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#Int().(key string, def int) int { |
| 85 | s, _ := e.Fetcherscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#Fetcher..Getscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Fetcher#Get.(key) |
| 86 | return Intscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Int().(s, def) |
| 87 | } |
| 88 | |
| 89 | func (e *environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#) Int64scip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#Int64().(key string, def int64) int64 { |
| 90 | s, _ := e.Fetcherscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#Fetcher..Getscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Fetcher#Get.(key) |
| 91 | return Int64scip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Int64().(s, def) |
| 92 | } |
| 93 | |
| 94 | func (e *environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#) Allscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#All().() map[string][]string { |
| 95 | return e.Fetcherscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/environment#Fetcher..Allscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Fetcher#All.() |
| 96 | } |
| 97 | |
| 98 | // Int returns the int value associated with the given value, or the value |
| 99 | // "def", if the value is blank. |
| 100 | // |
| 101 | // To convert from a the string value attached to a given key, |
| 102 | // `strconv.Atoi(val)` is called. If `Atoi` returned a non-nil error, |
| 103 | // then the value "def" will be returned instead. |
| 104 | // |
| 105 | // Otherwise, if the value was converted `string -> int` successfully, |
| 106 | // then it will be returned wholesale. |
| 107 | func Intscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Int().(value string, def int) int { |
| 108 | if len(value) == 0 { |
| 109 | return def |
| 110 | } |
| 111 | |
| 112 | i, err := strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/.Atoiscip-go gomod github.com/golang/go/src go1.25.0 strconv/Atoi().(value) |
| 113 | if err != nil { |
| 114 | return def |
| 115 | } |
| 116 | |
| 117 | return i |
| 118 | } |
| 119 | |
| 120 | // Int64 returns the int64 value associated with the given value, or the value |
| 121 | // "def", if the value is blank. |
| 122 | // |
| 123 | // To convert from the string value attached to a given key, |
| 124 | // `strconv.ParseInt(val, 10, 64)` is called. If `ParseInt` returned a |
| 125 | // non-nil error, then the value "def" will be returned instead. |
| 126 | // |
| 127 | // Otherwise, if the value was converted `string -> int64` successfully, |
| 128 | // then it will be returned wholesale. |
| 129 | func Int64scip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Int64().(value string, def int64) int64 { |
| 130 | if len(value) == 0 { |
| 131 | return def |
| 132 | } |
| 133 | |
| 134 | i, err := strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.25.0 strconv/ParseInt().(value, 10, 64) |
| 135 | if err != nil { |
| 136 | return def |
| 137 | } |
| 138 | |
| 139 | return i |
| 140 | } |
| 141 | |
| 142 | // Bool returns the boolean state associated with the given value, or the |
| 143 | // value "def", if the value is blank. |
| 144 | // |
| 145 | // The "boolean state associated with a given key" is defined as the |
| 146 | // case-insensitive string comparison with the following: |
| 147 | // |
| 148 | // 1. true if... |
| 149 | // "true", "1", "on", "yes", or "t" |
| 150 | // 2. false if... |
| 151 | // "false", "0", "off", "no", "f", or otherwise. |
| 152 | func Boolscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Bool().(value string, def bool) bool { |
| 153 | if len(value) == 0 { |
| 154 | return def |
| 155 | } |
| 156 | |
| 157 | switch stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.25.0 strings/ToLower().(value) { |
| 158 | case "true", "1", "on", "yes", "t": |
| 159 | return true |
| 160 | case "false", "0", "off", "no", "f": |
| 161 | return false |
| 162 | default: |
| 163 | return false |
| 164 | } |
| 165 | } |