exclude/cmd/context.go
onyx-and-iris 8059255d52 add del command
add tests for all commands

wrap entry point with fang

add --version flag
target to Taskfile
2026-03-29 21:15:56 +01:00

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
}