jawher / mow.cli

A versatile library for building CLI applications in Go
MIT License
871 stars 55 forks source link

Add CommandAction function #36

Closed andrzejressel closed 8 years ago

andrzejressel commented 8 years ago

When you just want to set Action when using Command

jawher commented 8 years ago

Thanks @jereksel for your contribution !

To keep the surface area as small as possible, and to avoid code duplication, what do you think about implementing this differently: instead of exposing a CommandAction function, provide instead a (top-level) function which takes the action function and returns one suitable for a command initializer ? Concretely, it would look like this:

app.Command("list", "list all configs", cli.ActionCommand(func()) {
  // ...
}))
andrzejressel commented 8 years ago

Sure, sound good to me

jawher commented 8 years ago

@jereksel Thanks for the quick fix. One last remark to handle and it should be good for mege 👍

jawher commented 8 years ago

@jereksel Thank you for your contribution !