Commit Graph

79 Commits

Author SHA1 Message Date
Trevor Brown
f125741fb5 Update code to use . instead of source 2021-05-21 12:03:06 -04:00
Trevor Brown
8bbefba072
chore: ban echo command (#806) 2020-09-22 08:27:52 +10:00
James Hegedus
50feef2a77
fix: CI formatting use editorconfig (#751) 2020-06-30 09:16:35 +10:00
Victor Hugo Borja
a26bed6586 Make sure extension commands are properly displayed by asdf help 2020-03-15 11:45:09 -06:00
Trevor Brown
8b90d883ee Require .bash extension for plugin extension commands 2020-03-02 13:13:20 -05:00
Trevor Brown
52cbf1165c Add .bash file extensions to files containing code executed by Bash 2020-03-02 12:48:05 -05:00
Victor Hugo Borja
b8dc5f1604 Run shfmt on bash files 2019-11-29 10:15:38 -06:00
Victor Hugo Borja
3f0fe57db9 Let asdf help show plugin commands when available.
Also fix `asdf list all` to work as subcommand. Fixes #602
2019-11-29 07:42:55 -06:00
Victor Hugo Borja
e968fe6142 Subcommand-aware command line interface. 2019-11-27 12:17:17 -06:00
Victor Hugo Borja
3dd35958dd Handle help command and no args given 2019-11-25 12:21:37 -06:00
Victor Hugo Borja
70099027c2 Move plugin extension command into it's own file.
Add a test for calling default command with arguments.
2019-11-25 12:07:55 -06:00
Victor Hugo Borja
a22733f819 Resolve asdf PLUGIN_NAME default command.
When calling `asdf foo` and the `foo` plugin provides a `bin/default-command`
2019-11-25 02:47:55 -06:00
Victor Hugo Borja
0e8e1f8f84 New feature: asdf extension commands
It's possible for plugins to define new asdf commands. This way plugins can extend asdf capabilities or expose utilities related to their managed tool.

For example, a `foo` plugin might expose the command `asdf foo bar` by providing an executable file at `bin/bar`.
If `bin/bar` is a file but has no executable bit set, then its considered a source-able bash script, and will be sourced
with all the functions in `$ASDF_DIR/lib/utils.sh` already loaded.

A good example of this feature is the `nodejs` plugin, where people must import the release team keyring before
installing a nodejs version. People can execute the following command without having to know where exactly is the plugin located.
2019-11-25 02:24:46 -06:00
Kevin Lane
36ba38d921
Add asdf latest command to show latest stable version of a tool 2019-11-22 10:37:52 -08:00
Jonathan Mast
9116e8453d
Add "shell" subcommand for setting versions in shell session
Add a "shell" command similar to the existing "global" and "local"
commands, which sets the version in an environment variable instead of
writing it to a file. This was inspired by the similar functionality in
rbenv.

It works by adding a wrapper function for the asdf command. It forwards
to a "sh-shell" command that returns the exports as shell code which is
then evaled by the wrapper. This is a little gross, but we need to run
the code in the shell context in order to set variables.

Resolves #378
2019-03-09 13:19:33 -05:00
Victor Hugo Borja
ab59e5618f Move common functionality to utils.sh
- Make shim-exec, shim-env, and which use the same logic to look for commands
- Make sure shim-exec and which use a plugin exec-path hook as documented
  (the hook takes a relative path to the executable and returns also
   a relative path, possibly modified)
- Fix shellchecks
2019-01-20 14:02:22 -06:00
Victor Hugo Borja
9cac0ac50a Faster exec times. Load commands only when nedded.
When testing, use `run asdf` to actually test the command
as the user would invoke it, so that we might catch possible
errors on `bin/asdf`.
2019-01-20 02:13:20 -06:00
Victor Hugo Borja
8927a4a09f Add asdf env command 2019-01-19 20:59:27 -06:00
Victor Hugo Borja
6da747b6ce Test that asdf exec works even if asdf shims are not in PATH. 2019-01-19 20:09:53 -06:00
Victor Hugo Borja
e51f778b61 Move bin/private/asdf-tool-exec to be asdf exec command
This way the code for executing shims can also be invoked via
`asdf exec <tool> [args..]` and can be linted.
2019-01-19 20:02:14 -06:00
Victor Hugo Borja
a46eaf3b4a Merge remote-tracking branch 'origin/shim-versions-command' into 0.6.4-dev 2019-01-19 13:56:56 -06:00
Victor Hugo Borja
9a79ac9526 user configurable pre-post command hooks
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: ${@}
```
2019-01-19 13:32:07 -06:00
Victor Hugo Borja
7fda291df0 Add asdf shim-versions command (#380)
For example `asdf shim-versions npm` will list the plugins and their
versions on which the `npm` command is available.

Based on #432
2019-01-19 13:31:26 -06:00
Victor Hugo Borja
9b27848d07 New shim metadata to allow many plugins with same executable names
Features

* New shim version meta-data allows shims to not depend on a particular plugin
  nor on its relative executable path (#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 (#431)
2019-01-19 13:22:12 -06:00
Trevor Brown
c37307a2cc Create get_custom_executable_path function to hold the custom exec path logic 2019-01-05 10:23:41 -05:00
Andrew Thauer
d94e0223bf Implement plugin hook to customize executable path
This feature allows the plugin to optionally change the executable path
of a shim prior to execution. This is useful when the plugin tool has
commands that may exist in multiple locations (like npm).
2018-04-25 22:18:34 -04:00
Edoardo Tenani
9f58c22e98 use exit code 127 when version is not installed 2018-04-05 23:59:35 +02:00
Edoardo Tenani
23bf434dbf use exit code 126 when version is not set 2018-04-05 23:59:31 +02:00
AJ Foster
eb5e5b780c Refactor "no version set" message to utilities 2018-02-25 18:33:42 -05:00
AJ Foster
c2fb6a3140 Escape backticks in command suggestion 2018-02-25 00:50:46 -05:00
AJ Foster
f15a0c9de3 Suggest action when no version is set 2018-02-25 00:40:26 -05:00
Victor Borja
8b40b30dec let bin/asdf expand args into command functions 2017-09-04 12:49:38 -05:00
Victor Borja
e814d58da3 Shellcheck all commands 2017-09-04 12:04:56 -05:00
Jonathan Knapp
9a3bd01ee4
Ignore following non-constant source 2017-09-04 10:09:47 -04:00
Jonathan Knapp
808a8d48b7
Fix many shellcheck issues; ignore a few others 2017-09-04 10:09:47 -04:00
Daniel Perez
b9fae70c0d Add plugin-list-all command 2017-08-25 11:29:23 +09:00
Fernando
1e9166e9bc Merge branch 'master' into which_command 2017-05-15 15:40:42 -03:00
Trevor Brown
0f7757a910 Correct if statements in asdf-exec and utils.sh. 2017-03-25 14:50:30 -04:00
Daniel Perez
f5152f255a WIP: support system version 2017-03-17 22:00:37 -04:00
Trevor Brown
5f39035850 Make sure update function is loaded. 2017-03-17 13:07:30 -04:00
Fernando Crespo
fb4e263598 Initial support for which command 2017-03-14 10:56:59 -03:00
Kevin Rockwood
ca1273e7d4 Rename which to current (#79)
* Rename `asdf which` -> `asdf current`

* Output `set by $path` with current command

* Use dummy plugin in current_command test

* Hide "set by" message if derived from legacy file
2016-07-25 00:47:17 +09:00
Laurens Duijvesteijn
337b335c4d Check if plugin exists before removing it (#77)
Check if plugin exists before removing it
2016-07-06 08:19:15 +09:00
Akash Manohar
c3765182f8 Merge pull request #51 from tuvistavie/use-multiple-versions
Make it possible to use fallback versions. Thank you @tuvistavie ~!
2016-05-14 15:19:29 +05:30
Daniel Perez
072a57e4cb Add command and instructions to test plugin. 2016-05-13 16:04:01 +09:00
Daniel Perez
3e31c40020 Make it possible to use fallback versions. 2016-05-04 02:22:48 +09:00
Daniel Perez
784d7e9f34 Add support for local and global commands. 2016-04-25 02:13:09 +09:00
Martin Schürrer
aaa8abfd23 Don't spawn subshells, use exec 2015-10-01 19:31:53 +02:00
Martin Schürrer
78d516d063 Fix path: syntax in .tools-version 2015-08-11 12:33:08 +02:00
Kevin Disneur
c2fc8dd34e
Add a command to list the plugins already installed 2015-06-14 13:37:48 +01:00