Skip to content

Support cmd.Use(fn).Run(fn) #5

@matthewmueller

Description

@matthewmueller

When you have to configure global dependencies like the logger, you currently need to wrap the runners

func wrap(fn func(ctx context.Context) error) func(ctx context.Context) error {
	return func(ctx context.Context) error {
		return fn(ctx)
	}
}

// usage

cmd.Run(wrap(func(ctx context.Context) error {
	return c.Download(ctx, in)
}))

This isn't bad, but it'd be nice to able to just call cmd.Use(...).Run(...) to configure "middleware". Ideally you could do it higher up, so you don't need to do it for every command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions