cli
cli copied to clipboard
[poc] do not merge!
trafficstars
the idea is to get rid of cli.Context wherever that is possible in order to get a reusable importable code.
the problem is that most of the function relies on cli.Context, this context is used for CLI flags only, so instead of passing a context down, we may retrieve necessary flag values to then pass them instead.
2nd thing is CLI command structs like:
type initFnCmd struct {
force bool
triggerType string
wd string
ff *common.FuncFile
ffV20180707 *common.FuncFileV20180707
}
most of the methods implemented on this struct are using func file, nothing else, so, in order to make code reusable we need to do two things (true way and an alternative):
- extract core logic of those methods and make it reusable
- make those methods structure-independent (i.e., if a method needs a reference to any of structure attributes - pass them as parameters, but not through a struct pointer reference).
I'm talking about specific method like:
func bindRoute(ff *common.FuncFile, fn *models.Route)
func bindFn(ff *common.FuncFileV20180707, fn *modelsV2.Fn)
etc