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

Added cli_boot and cli_before_handle extension hook to run on each CLI request; #2846 #3409

Merged
merged 8 commits into from
Nov 8, 2023

Conversation

intoeetive
Copy link
Contributor

Added cli_boot extension hook to run on each CLI request; closes #2846

@intoeetive intoeetive added this to the 7.2.18 milestone May 17, 2023
@intoeetive intoeetive modified the milestones: 7.3.6, 7.4.0 Jun 29, 2023
@intoeetive intoeetive added the docs covered Has User Guide PR, or no documentaion necessary label Oct 24, 2023
@matthewjohns0n matthewjohns0n changed the base branch from 7.dev to release/7.4.0 November 1, 2023 17:19
@matthewjohns0n
Copy link
Member

Just wanted to note that this hook gets called after the help command is run. If the help command is run, this hook never fires.

Part of me thinks this should be run before the help command. @bryannielsen can you weigh in on this?

@bryannielsen
Copy link
Contributor

@matthewjohns0n yea I would agree that if we're calling this a boot hook I would move it as early as possible in the process and definitely before anything can be sent as output.

@matthewjohns0n matthewjohns0n changed the title Added cli_boot extension hook to run on each CLI request; #2846 Added cli_boot and cli_before_handle extension hook to run on each CLI request; #2846 Nov 1, 2023
@matthewjohns0n
Copy link
Member

FYI - I ended up splitting this into 2 hooks, which both seem to have application here. cli_boot is the hook that is run before anything happens with the CLI command. This allows an add-on dev to potentially hook into commands and adjust parameters or something along those lines.

cli_before_handle is the command that runs right before the CLI handle() function is run. At this point, the command may have failed due to not being found or other processing may happen instead, like the help command. We only run this hook directly before actually running a CLI command.

@intoeetive
Copy link
Contributor Author

@bryannielsen @matthewjohns0n do we need second review on this?

@bryannielsen bryannielsen self-assigned this Nov 8, 2023
@bryannielsen bryannielsen merged commit e884b89 into release/7.4.0 Nov 8, 2023
21 of 22 checks passed
@bryannielsen bryannielsen deleted the feature/7.x/cli-boot-hook branch November 8, 2023 20:09
@matthewjohns0n matthewjohns0n self-assigned this Nov 13, 2023
@intoeetive
Copy link
Contributor Author

@matthewjohns0n the order of parameters in extensions generator was wrong, I fixed it.

I also discovered that cli_boot hook does not really allow you to "hook into commands and adjust parameters" as per your comment. I could only display extra stuff, not modify parameters or anything... Which really makes the usability of it questionable. So perhaps we should just remove it?

I also updated the docs, leaving that for you to review

@matthewjohns0n
Copy link
Member

Thanks for fixing that parameter order @intoeetive. I'm going to test the hooks tomorrow morning and I'll loop back on this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development docs covered Has User Guide PR, or no documentaion necessary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

core_boot hook is not called when using CLI commands
3 participants