WithCommandFlags creates a new context with the given flags
(parent context.Context, flagSet *flag.FlagSet)
| 27 | |
| 28 | // WithCommandFlags creates a new context with the given flags |
| 29 | func WithCommandFlags(parent context.Context, flagSet *flag.FlagSet) context.Context { |
| 30 | flagsMap := map[string]string{} |
| 31 | flagSet.VisitAll(func(f *flag.Flag) { |
| 32 | sliceType, ok := f.Value.(flag.SliceValue) |
| 33 | if ok { |
| 34 | flagsMap[f.Name] = strings.Join(sliceType.GetSlice(), " ") |
| 35 | } else { |
| 36 | flagsMap[f.Name] = f.Value.String() |
| 37 | } |
| 38 | }) |
| 39 | |
| 40 | gfc := WithValue(parent, commandFlagsKey, flagsMap) |
| 41 | return WithValue(gfc, flagsKey, flagsMap) |
| 42 | } |
| 43 | |
| 44 | // FlagsFrom returns a context used to start and stop dev configurations |
| 45 | func FlagsFrom(ctx context.Context) (map[string]string, bool) { |
no test coverage detected