Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spawn: autoload_function flexibility such that it can be called not just at top of script #37

Open
icasimpan opened this issue Apr 9, 2023 · 0 comments

Comments

@icasimpan
Copy link
Collaborator

icasimpan commented Apr 9, 2023

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant