From 5760a88db3a3160fd90fd39067d2c024edd23e08 Mon Sep 17 00:00:00 2001 From: Jamie Markle Date: Mon, 15 Aug 2016 15:22:50 -0400 Subject: [PATCH] add WrapProcess --- commands.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/commands.go b/commands.go index 769dcb1c..d7f22495 100644 --- a/commands.go +++ b/commands.go @@ -245,6 +245,14 @@ type cmdable struct { process func(cmd Cmder) error } +// WrapProcess replaces the process func. It takes a function createWrapper +// which is supplied by the user. createWrapper takes the old process func as +// an input and returns the new wrapper process func. createWrapper should +// use call the old process func within the new process func. +func (c *cmdable) WrapProcess(createWrapper func(oldProcess func(cmd Cmder) error) func(cmd Cmder) error) { + c.process = createWrapper(c.process) +} + var _ Cmdable = (*cmdable)(nil) type statefulCmdable struct {