summaryrefslogtreecommitdiff
path: root/vendor/github.com/mitchellh
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-22 17:35:49 -0600
committermo khan <mo@mokhan.ca>2025-07-22 17:35:49 -0600
commit20ef0d92694465ac86b550df139e8366a0a2b4fa (patch)
tree3f14589e1ce6eb9306a3af31c3a1f9e1af5ed637 /vendor/github.com/mitchellh
parent44e0d272c040cdc53a98b9f1dc58ae7da67752e6 (diff)
feat: connect to spicedb
Diffstat (limited to 'vendor/github.com/mitchellh')
-rw-r--r--vendor/github.com/mitchellh/colorstring/.travis.yml15
-rw-r--r--vendor/github.com/mitchellh/colorstring/LICENSE21
-rw-r--r--vendor/github.com/mitchellh/colorstring/README.md30
-rw-r--r--vendor/github.com/mitchellh/colorstring/colorstring.go244
-rw-r--r--vendor/github.com/mitchellh/go-homedir/LICENSE21
-rw-r--r--vendor/github.com/mitchellh/go-homedir/README.md14
-rw-r--r--vendor/github.com/mitchellh/go-homedir/homedir.go167
7 files changed, 512 insertions, 0 deletions
diff --git a/vendor/github.com/mitchellh/colorstring/.travis.yml b/vendor/github.com/mitchellh/colorstring/.travis.yml
new file mode 100644
index 0000000..74e286a
--- /dev/null
+++ b/vendor/github.com/mitchellh/colorstring/.travis.yml
@@ -0,0 +1,15 @@
+language: go
+
+go:
+ - 1.0
+ - 1.1
+ - 1.2
+ - 1.3
+ - tip
+
+script:
+ - go test
+
+matrix:
+ allow_failures:
+ - go: tip
diff --git a/vendor/github.com/mitchellh/colorstring/LICENSE b/vendor/github.com/mitchellh/colorstring/LICENSE
new file mode 100644
index 0000000..2298515
--- /dev/null
+++ b/vendor/github.com/mitchellh/colorstring/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Mitchell Hashimoto
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/vendor/github.com/mitchellh/colorstring/README.md b/vendor/github.com/mitchellh/colorstring/README.md
new file mode 100644
index 0000000..0654d45
--- /dev/null
+++ b/vendor/github.com/mitchellh/colorstring/README.md
@@ -0,0 +1,30 @@
+# colorstring [![Build Status](https://travis-ci.org/mitchellh/colorstring.svg)](https://travis-ci.org/mitchellh/colorstring)
+
+colorstring is a [Go](http://www.golang.org) library for outputting colored
+strings to a console using a simple inline syntax in your string to specify
+the color to print as.
+
+For example, the string `[blue]hello [red]world` would output the text
+"hello world" in two colors. The API of colorstring allows for easily disabling
+colors, adding aliases, etc.
+
+## Installation
+
+Standard `go get`:
+
+```
+$ go get github.com/mitchellh/colorstring
+```
+
+## Usage & Example
+
+For usage and examples see the [Godoc](http://godoc.org/github.com/mitchellh/colorstring).
+
+Usage is easy enough:
+
+```go
+colorstring.Println("[blue]Hello [red]World!")
+```
+
+Additionally, the `Colorize` struct can be used to set options such as
+custom colors, color disabling, etc.
diff --git a/vendor/github.com/mitchellh/colorstring/colorstring.go b/vendor/github.com/mitchellh/colorstring/colorstring.go
new file mode 100644
index 0000000..3de5b24
--- /dev/null
+++ b/vendor/github.com/mitchellh/colorstring/colorstring.go
@@ -0,0 +1,244 @@
+// colorstring provides functions for colorizing strings for terminal
+// output.
+package colorstring
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "regexp"
+ "strings"
+)
+
+// Color colorizes your strings using the default settings.
+//
+// Strings given to Color should use the syntax `[color]` to specify the
+// color for text following. For example: `[blue]Hello` will return "Hello"
+// in blue. See DefaultColors for all the supported colors and attributes.
+//
+// If an unrecognized color is given, it is ignored and assumed to be part
+// of the string. For example: `[hi]world` will result in "[hi]world".
+//
+// A color reset is appended to the end of every string. This will reset
+// the color of following strings when you output this text to the same
+// terminal session.
+//
+// If you want to customize any of this behavior, use the Colorize struct.
+func Color(v string) string {
+ return def.Color(v)
+}
+
+// ColorPrefix returns the color sequence that prefixes the given text.
+//
+// This is useful when wrapping text if you want to inherit the color
+// of the wrapped text. For example, "[green]foo" will return "[green]".
+// If there is no color sequence, then this will return "".
+func ColorPrefix(v string) string {
+ return def.ColorPrefix(v)
+}
+
+// Colorize colorizes your strings, giving you the ability to customize
+// some of the colorization process.
+//
+// The options in Colorize can be set to customize colorization. If you're
+// only interested in the defaults, just use the top Color function directly,
+// which creates a default Colorize.
+type Colorize struct {
+ // Colors maps a color string to the code for that color. The code
+ // is a string so that you can use more complex colors to set foreground,
+ // background, attributes, etc. For example, "boldblue" might be
+ // "1;34"
+ Colors map[string]string
+
+ // If true, color attributes will be ignored. This is useful if you're
+ // outputting to a location that doesn't support colors and you just
+ // want the strings returned.
+ Disable bool
+
+ // Reset, if true, will reset the color after each colorization by
+ // adding a reset code at the end.
+ Reset bool
+}
+
+// Color colorizes a string according to the settings setup in the struct.
+//
+// For more details on the syntax, see the top-level Color function.
+func (c *Colorize) Color(v string) string {
+ matches := parseRe.FindAllStringIndex(v, -1)
+ if len(matches) == 0 {
+ return v
+ }
+
+ result := new(bytes.Buffer)
+ colored := false
+ m := []int{0, 0}
+ for _, nm := range matches {
+ // Write the text in between this match and the last
+ result.WriteString(v[m[1]:nm[0]])
+ m = nm
+
+ var replace string
+ if code, ok := c.Colors[v[m[0]+1:m[1]-1]]; ok {
+ colored = true
+
+ if !c.Disable {
+ replace = fmt.Sprintf("\033[%sm", code)
+ }
+ } else {
+ replace = v[m[0]:m[1]]
+ }
+
+ result.WriteString(replace)
+ }
+ result.WriteString(v[m[1]:])
+
+ if colored && c.Reset && !c.Disable {
+ // Write the clear byte at the end
+ result.WriteString("\033[0m")
+ }
+
+ return result.String()
+}
+
+// ColorPrefix returns the first color sequence that exists in this string.
+//
+// For example: "[green]foo" would return "[green]". If no color sequence
+// exists, then "" is returned. This is especially useful when wrapping
+// colored texts to inherit the color of the wrapped text.
+func (c *Colorize) ColorPrefix(v string) string {
+ return prefixRe.FindString(strings.TrimSpace(v))
+}
+
+// DefaultColors are the default colors used when colorizing.
+//
+// If the color is surrounded in underscores, such as "_blue_", then that
+// color will be used for the background color.
+var DefaultColors map[string]string
+
+func init() {
+ DefaultColors = map[string]string{
+ // Default foreground/background colors
+ "default": "39",
+ "_default_": "49",
+
+ // Foreground colors
+ "black": "30",
+ "red": "31",
+ "green": "32",
+ "yellow": "33",
+ "blue": "34",
+ "magenta": "35",
+ "cyan": "36",
+ "light_gray": "37",
+ "dark_gray": "90",
+ "light_red": "91",
+ "light_green": "92",
+ "light_yellow": "93",
+ "light_blue": "94",
+ "light_magenta": "95",
+ "light_cyan": "96",
+ "white": "97",
+
+ // Background colors
+ "_black_": "40",
+ "_red_": "41",
+ "_green_": "42",
+ "_yellow_": "43",
+ "_blue_": "44",
+ "_magenta_": "45",
+ "_cyan_": "46",
+ "_light_gray_": "47",
+ "_dark_gray_": "100",
+ "_light_red_": "101",
+ "_light_green_": "102",
+ "_light_yellow_": "103",
+ "_light_blue_": "104",
+ "_light_magenta_": "105",
+ "_light_cyan_": "106",
+ "_white_": "107",
+
+ // Attributes
+ "bold": "1",
+ "dim": "2",
+ "underline": "4",
+ "blink_slow": "5",
+ "blink_fast": "6",
+ "invert": "7",
+ "hidden": "8",
+
+ // Reset to reset everything to their defaults
+ "reset": "0",
+ "reset_bold": "21",
+ }
+
+ def = Colorize{
+ Colors: DefaultColors,
+ Reset: true,
+ }
+}
+
+var def Colorize
+var parseReRaw = `\[[a-z0-9_-]+\]`
+var parseRe = regexp.MustCompile(`(?i)` + parseReRaw)
+var prefixRe = regexp.MustCompile(`^(?i)(` + parseReRaw + `)+`)
+
+// Print is a convenience wrapper for fmt.Print with support for color codes.
+//
+// Print formats using the default formats for its operands and writes to
+// standard output with support for color codes. Spaces are added between
+// operands when neither is a string. It returns the number of bytes written
+// and any write error encountered.
+func Print(a string) (n int, err error) {
+ return fmt.Print(Color(a))
+}
+
+// Println is a convenience wrapper for fmt.Println with support for color
+// codes.
+//
+// Println formats using the default formats for its operands and writes to
+// standard output with support for color codes. Spaces are always added
+// between operands and a newline is appended. It returns the number of bytes
+// written and any write error encountered.
+func Println(a string) (n int, err error) {
+ return fmt.Println(Color(a))
+}
+
+// Printf is a convenience wrapper for fmt.Printf with support for color codes.
+//
+// Printf formats according to a format specifier and writes to standard output
+// with support for color codes. It returns the number of bytes written and any
+// write error encountered.
+func Printf(format string, a ...interface{}) (n int, err error) {
+ return fmt.Printf(Color(format), a...)
+}
+
+// Fprint is a convenience wrapper for fmt.Fprint with support for color codes.
+//
+// Fprint formats using the default formats for its operands and writes to w
+// with support for color codes. Spaces are added between operands when neither
+// is a string. It returns the number of bytes written and any write error
+// encountered.
+func Fprint(w io.Writer, a string) (n int, err error) {
+ return fmt.Fprint(w, Color(a))
+}
+
+// Fprintln is a convenience wrapper for fmt.Fprintln with support for color
+// codes.
+//
+// Fprintln formats using the default formats for its operands and writes to w
+// with support for color codes. Spaces are always added between operands and a
+// newline is appended. It returns the number of bytes written and any write
+// error encountered.
+func Fprintln(w io.Writer, a string) (n int, err error) {
+ return fmt.Fprintln(w, Color(a))
+}
+
+// Fprintf is a convenience wrapper for fmt.Fprintf with support for color
+// codes.
+//
+// Fprintf formats according to a format specifier and writes to w with support
+// for color codes. It returns the number of bytes written and any write error
+// encountered.
+func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
+ return fmt.Fprintf(w, Color(format), a...)
+}
diff --git a/vendor/github.com/mitchellh/go-homedir/LICENSE b/vendor/github.com/mitchellh/go-homedir/LICENSE
new file mode 100644
index 0000000..f9c841a
--- /dev/null
+++ b/vendor/github.com/mitchellh/go-homedir/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2013 Mitchell Hashimoto
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/vendor/github.com/mitchellh/go-homedir/README.md b/vendor/github.com/mitchellh/go-homedir/README.md
new file mode 100644
index 0000000..d70706d
--- /dev/null
+++ b/vendor/github.com/mitchellh/go-homedir/README.md
@@ -0,0 +1,14 @@
+# go-homedir
+
+This is a Go library for detecting the user's home directory without
+the use of cgo, so the library can be used in cross-compilation environments.
+
+Usage is incredibly simple, just call `homedir.Dir()` to get the home directory
+for a user, and `homedir.Expand()` to expand the `~` in a path to the home
+directory.
+
+**Why not just use `os/user`?** The built-in `os/user` package requires
+cgo on Darwin systems. This means that any Go code that uses that package
+cannot cross compile. But 99% of the time the use for `os/user` is just to
+retrieve the home directory, which we can do for the current user without
+cgo. This library does that, enabling cross-compilation.
diff --git a/vendor/github.com/mitchellh/go-homedir/homedir.go b/vendor/github.com/mitchellh/go-homedir/homedir.go
new file mode 100644
index 0000000..2537853
--- /dev/null
+++ b/vendor/github.com/mitchellh/go-homedir/homedir.go
@@ -0,0 +1,167 @@
+package homedir
+
+import (
+ "bytes"
+ "errors"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
+ "strconv"
+ "strings"
+ "sync"
+)
+
+// DisableCache will disable caching of the home directory. Caching is enabled
+// by default.
+var DisableCache bool
+
+var homedirCache string
+var cacheLock sync.RWMutex
+
+// Dir returns the home directory for the executing user.
+//
+// This uses an OS-specific method for discovering the home directory.
+// An error is returned if a home directory cannot be detected.
+func Dir() (string, error) {
+ if !DisableCache {
+ cacheLock.RLock()
+ cached := homedirCache
+ cacheLock.RUnlock()
+ if cached != "" {
+ return cached, nil
+ }
+ }
+
+ cacheLock.Lock()
+ defer cacheLock.Unlock()
+
+ var result string
+ var err error
+ if runtime.GOOS == "windows" {
+ result, err = dirWindows()
+ } else {
+ // Unix-like system, so just assume Unix
+ result, err = dirUnix()
+ }
+
+ if err != nil {
+ return "", err
+ }
+ homedirCache = result
+ return result, nil
+}
+
+// Expand expands the path to include the home directory if the path
+// is prefixed with `~`. If it isn't prefixed with `~`, the path is
+// returned as-is.
+func Expand(path string) (string, error) {
+ if len(path) == 0 {
+ return path, nil
+ }
+
+ if path[0] != '~' {
+ return path, nil
+ }
+
+ if len(path) > 1 && path[1] != '/' && path[1] != '\\' {
+ return "", errors.New("cannot expand user-specific home dir")
+ }
+
+ dir, err := Dir()
+ if err != nil {
+ return "", err
+ }
+
+ return filepath.Join(dir, path[1:]), nil
+}
+
+// Reset clears the cache, forcing the next call to Dir to re-detect
+// the home directory. This generally never has to be called, but can be
+// useful in tests if you're modifying the home directory via the HOME
+// env var or something.
+func Reset() {
+ cacheLock.Lock()
+ defer cacheLock.Unlock()
+ homedirCache = ""
+}
+
+func dirUnix() (string, error) {
+ homeEnv := "HOME"
+ if runtime.GOOS == "plan9" {
+ // On plan9, env vars are lowercase.
+ homeEnv = "home"
+ }
+
+ // First prefer the HOME environmental variable
+ if home := os.Getenv(homeEnv); home != "" {
+ return home, nil
+ }
+
+ var stdout bytes.Buffer
+
+ // If that fails, try OS specific commands
+ if runtime.GOOS == "darwin" {
+ cmd := exec.Command("sh", "-c", `dscl -q . -read /Users/"$(whoami)" NFSHomeDirectory | sed 's/^[^ ]*: //'`)
+ cmd.Stdout = &stdout
+ if err := cmd.Run(); err == nil {
+ result := strings.TrimSpace(stdout.String())
+ if result != "" {
+ return result, nil
+ }
+ }
+ } else {
+ cmd := exec.Command("getent", "passwd", strconv.Itoa(os.Getuid()))
+ cmd.Stdout = &stdout
+ if err := cmd.Run(); err != nil {
+ // If the error is ErrNotFound, we ignore it. Otherwise, return it.
+ if err != exec.ErrNotFound {
+ return "", err
+ }
+ } else {
+ if passwd := strings.TrimSpace(stdout.String()); passwd != "" {
+ // username:password:uid:gid:gecos:home:shell
+ passwdParts := strings.SplitN(passwd, ":", 7)
+ if len(passwdParts) > 5 {
+ return passwdParts[5], nil
+ }
+ }
+ }
+ }
+
+ // If all else fails, try the shell
+ stdout.Reset()
+ cmd := exec.Command("sh", "-c", "cd && pwd")
+ cmd.Stdout = &stdout
+ if err := cmd.Run(); err != nil {
+ return "", err
+ }
+
+ result := strings.TrimSpace(stdout.String())
+ if result == "" {
+ return "", errors.New("blank output when reading home directory")
+ }
+
+ return result, nil
+}
+
+func dirWindows() (string, error) {
+ // First prefer the HOME environmental variable
+ if home := os.Getenv("HOME"); home != "" {
+ return home, nil
+ }
+
+ // Prefer standard environment variable USERPROFILE
+ if home := os.Getenv("USERPROFILE"); home != "" {
+ return home, nil
+ }
+
+ drive := os.Getenv("HOMEDRIVE")
+ path := os.Getenv("HOMEPATH")
+ home := drive + path
+ if drive == "" || path == "" {
+ return "", errors.New("HOMEDRIVE, HOMEPATH, or USERPROFILE are blank")
+ }
+
+ return home, nil
+}