mirror of
https://github.com/onyx-and-iris/exclude.git
synced 2026-03-30 23:19:09 +00:00
add tests for all commands wrap entry point with fang add --version flag target to Taskfile
29 lines
522 B
Go
29 lines
522 B
Go
package cmd
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"os"
|
|
)
|
|
|
|
type contextKey string
|
|
|
|
const contextObjectKey = contextKey("contextObject")
|
|
|
|
type contextObject struct {
|
|
File *os.File
|
|
Out io.Writer
|
|
}
|
|
|
|
func createContext(file *os.File, out io.Writer) context.Context {
|
|
return context.WithValue(context.Background(), contextObjectKey, &contextObject{
|
|
File: file,
|
|
Out: out,
|
|
})
|
|
}
|
|
|
|
func ContextObjectFromContext(ctx context.Context) (*contextObject, bool) {
|
|
obj, ok := ctx.Value(contextObjectKey).(*contextObject)
|
|
return obj, ok
|
|
}
|