Right now, spawn functionality expects that autoload_functions is located at the top of the script as implemented in https://github.com/shsdk/shcf/blob/master/core/lib/create_spawn.bash.inc#L66-L68
Sometimes, for performance reason, autoload_functions is called as needed.
For instance, in shcf_cli code traditionally define function names and autoload them at once, like https://github.com/shsdk/shcf/blob/master/core/bin/shcf_cli#L26-L41 is fine.
But how about when for performance reason (when your codebase becomes huge and you see that you don't really need to source all the functions at once and it improves x100 in code speed. Say, it takes a lot of time to load the create_bin function when you seldom need it.
So what you can do is recode and remove the "create_bin" from the top autoload_functions and do it this way:
"bin")
autoload_functions "create_bin"
create_bin $project $new_entity
;;
instead of https://github.com/shsdk/shcf/blob/master/core/bin/shcf_cli#L80-L82
Well, then spawn doesn't support it yet.
Implementation Idea
Same as #36, there would be some sort of spawn conf that would indicate if there's only 1 autoload (which is always at the top of the script) or multiple.
- Single autoload - no changes to current implementation
- Multiple autoload - parse the script, gather all the autoload