MCPcopy Index your code
hub / github.com/smallstep/cli / wrap

Function wrap

internal/command/inject.go:40–56  ·  view source on GitHub ↗

wrap wraps a function with middleware using a new context. It returns a cli.ActionFunc with the cli.Context added to the Context.

(fn func(context.Context) error, middleware ...func(context.Context) (context.Context, error))

Source from the content-addressed store, hash-verified

38// wrap wraps a function with middleware using a new context. It returns a cli.ActionFunc with
39// the cli.Context added to the Context.
40func wrap(fn func(context.Context) error, middleware ...func(context.Context) (context.Context, error)) cli.ActionFunc {
41 return func(clictx *cli.Context) error {
42 ctx := context.Background()
43
44 // apply middleware to the new context
45 for _, fn := range middleware {
46 var err error
47 if ctx, err = fn(ctx); err != nil {
48 return err
49 }
50 }
51
52 ctx = withCLIContext(ctx, clictx)
53
54 return fn(ctx)
55 }
56}

Callers 1

InjectContextFunction · 0.85

Calls 1

withCLIContextFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…