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

user configurable pre-post command hooks #434

Merged
merged 7 commits into from
Jan 19, 2019
Merged

Conversation

vic
Copy link
Contributor

@vic vic commented Jan 19, 2019

Suppose a foo plugin is installed and provides a bar executable.
The following hooks will be executed when set in .asdfrc:

 pre_asdf_install_foo = echo will install foo version ${1}
 post_asdf_install_foo = echo installed foo version ${1}

 pre_asdf_reshim_foo = echo will reshim foo version ${1}
 post_asdf_reshim_foo = echo reshimmed foo version ${1}
    
 pre_foo_bar = echo about to execute command bar from foo with args: ${@}
 post_foo_bar = echo just executed command bar from foo with args: ${@}

Based on changes from #432

Features

* New shim version meta-data allows shims to not depend on a particular plugin
  nor on its relative executable path (asdf-vm#431)
  Upgrading requires shim re-generation and should happen automatically
  by `asdf-exec`:
    `rm -rf ~/.asdf/shims/` followed by `asdf reshim`
* Added lots of tests for shim execution.
  We now make sure that shim execution obeys plugins hooks like
  `list-bin-paths` and `exec-path`.
* Shim exec is now performed by a new `bin/private/asdf-tool-exec` that might
  be faster for most common use case: (versions on local .tool-versions file)
  but fallbacks to slower `get_preset_version_for` which takes legacy formats
  into account.
* Shim exec recommends which plugins or versions to set when command is
  not found.

Fixed Bugs

* Allow many plugins to provide shims with same executable name (asdf-vm#431)
Features

* New shim version meta-data allows shims to not depend on a particular plugin
  nor on its relative executable path (asdf-vm#431)
  Upgrading requires shim re-generation and should happen automatically
  by `asdf-exec`:
    `rm -rf ~/.asdf/shims/` followed by `asdf reshim`
* Added lots of tests for shim execution.
  We now make sure that shim execution obeys plugins hooks like
  `list-bin-paths` and `exec-path`.
* Shim exec is now performed by a new `bin/private/asdf-tool-exec` that might
  be faster for most common use case: (versions on local .tool-versions file)
  but fallbacks to slower `get_preset_version_for` which takes legacy formats
  into account.
* Shim exec recommends which plugins or versions to set when command is
  not found.

Fixed Bugs

* Allow many plugins to provide shims with same executable name (asdf-vm#431)
Suppose a `foo` plugin is installed and provides a `bar` executable.
The following hooks will be executed when set in `.asdfrc`:

```shell
post_asdf_install_foo = echo installed foo version ${1}
post_asdf_reshim_foo = echo reshimmed foo version ${1}

pre_foo_bar = echo about to execute command bar from foo with args: ${@}
post_foo_bar = echo just executed command bar from foo with args: ${@}
```
@vic vic changed the title WIP: user configurable pre-post command hooks user configurable pre-post command hooks Jan 19, 2019
@vic vic merged commit 9420ca1 into asdf-vm:master Jan 19, 2019
if [ -n "$hook_cmd" ]; then
asdf_hook_fun() {
unset asdf_hook_fun
ev'al' "$hook_cmd" # ignore banned command just here
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't just $hook_cmd be equivalent to this code?

@colinta
Copy link

colinta commented Feb 14, 2020

@vic I've been trying to get a post hook installed (auto-reshim after running pip) but either I'm misunderstanding the documentation or something is wrong... I checked that pip is being run via asdf:

which pip
/Users/colinta/.asdf/shims/pip

And I added this to ~/.asdfrc

post_python_pip = echo Just executed pip

but pip install foo doesn't run that command. 🤷‍♂

@Stratus3D
Copy link
Member

Stratus3D commented Mar 18, 2020

@colinta since pip is the executable I think you'd need something like post_python_pip = echo Just executed pip.

@vic
Copy link
Contributor Author

vic commented Mar 18, 2020

@colinta Looks like a bug in documentation now, since those post-command-hooks have already been removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants