2019-05-30 23:11:13 +01:00
|
|
|
package cli
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
2021-08-31 10:05:08 +02:00
|
|
|
"github.com/urfave/cli/v2"
|
2026-06-18 11:55:35 +01:00
|
|
|
"go-micro.dev/v6/config/source"
|
2019-05-30 23:11:13 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type contextKey struct{}
|
|
|
|
|
|
2022-09-30 16:27:07 +02:00
|
|
|
// Context sets the cli context.
|
2019-05-30 23:11:13 +01:00
|
|
|
func Context(c *cli.Context) source.Option {
|
|
|
|
|
return func(o *source.Options) {
|
|
|
|
|
if o.Context == nil {
|
|
|
|
|
o.Context = context.Background()
|
|
|
|
|
}
|
|
|
|
|
o.Context = context.WithValue(o.Context, contextKey{}, c)
|
|
|
|
|
}
|
|
|
|
|
}
|