github.com/annwntech/go-micro/v2@v2.9.5/config/source/cli/options.go (about)

     1  package cli
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/micro/cli/v2"
     7  	"github.com/annwntech/go-micro/v2/config/source"
     8  )
     9  
    10  type contextKey struct{}
    11  
    12  // Context sets the cli context
    13  func Context(c *cli.Context) source.Option {
    14  	return func(o *source.Options) {
    15  		if o.Context == nil {
    16  			o.Context = context.Background()
    17  		}
    18  		o.Context = context.WithValue(o.Context, contextKey{}, c)
    19  	}
    20  }