asdf/README.md

173 lines
3.9 KiB
Markdown
Raw Normal View History

2014-12-18 12:08:02 -07:00
# asdf
### _extendable version manager_
2014-09-29 09:51:09 -07:00
2014-12-18 12:08:02 -07:00
Feel free to add support for the language you want. There's a [simple API](#creating-package-sources) for it. Read the [ballad](https://github.com/HashNuke/asdf/blob/master/ballad-of-asdf.md).
2014-09-29 09:51:09 -07:00
2014-12-18 12:08:02 -07:00
[![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.3.0/dist/gratipay.png)](https://gratipay.com/HashNuke/)
2014-11-30 06:46:11 -07:00
2014-11-30 20:32:14 -07:00
## Table of Contents
2014-11-30 06:46:11 -07:00
2014-11-30 20:32:14 -07:00
* [Install](#install)
* [Manage sources](#manage-sources)
* [Manage packages](#manage-packages)
2014-11-30 20:47:19 -07:00
* [The `.versions` file](#the-versions-file)
2014-11-30 20:32:14 -07:00
* [Creating package sources](#creating-package-sources)
2014-11-30 06:46:11 -07:00
2014-11-30 20:32:14 -07:00
## Install
2014-11-30 06:46:11 -07:00
2014-11-30 20:32:14 -07:00
Copy-paste the following into command line:
2014-11-30 06:46:11 -07:00
2014-11-30 20:32:14 -07:00
```bash
git clone https://github.com/HashNuke/asdf.git ~/.asdf
echo 'export PATH="$HOME/.asdf/bin:$PATH"' >> ~/.bash_profile
2014-11-30 06:46:11 -07:00
```
2014-11-30 20:32:14 -07:00
**That's all ~! You are ready to use asdf**
2014-11-30 06:46:11 -07:00
2014-11-30 20:32:14 -07:00
It clones the adsf repo and adds `~/.asdf/bin` to `$PATH` in `~/.bash_profile`.
## Manage sources
Sources are how asdf understands how to handle packages.
2014-11-30 06:46:11 -07:00
2014-11-30 20:32:14 -07:00
#### Add a package
```bash
# asdf source-add <name> <git-url>
asdf source-add erlang https://github.com/HashNuke/asdf-erlang.git
2014-11-30 06:46:11 -07:00
```
2014-11-30 20:32:14 -07:00
#### Remove a source
```bash
# asdf source-remove <name>
2014-11-30 06:46:11 -07:00
asdf source-remove erlang
```
2014-11-30 20:32:14 -07:00
#### Update sources
2014-11-30 06:46:11 -07:00
2014-11-30 20:32:14 -07:00
```bash
# To update all sources
asdf source-update --all
2014-11-30 06:46:11 -07:00
```
If you want to update a specific package, just say so.
2014-11-30 20:32:14 -07:00
```bash
# asdf source-update <name>
asdf source-update erlang
2014-11-30 06:46:11 -07:00
```
## Manage packages
2014-11-30 20:32:14 -07:00
```bash
2014-11-30 06:46:11 -07:00
# asdf install <name> <version>
asdf install erlang 17.3
# asdf uninstall <name> <version>
asdf uninstall erlang 17.3
```
#### Lists installed versions
2014-11-30 20:32:14 -07:00
```bash
2014-11-30 06:46:11 -07:00
# asdf list <name>
2014-11-30 20:32:14 -07:00
asdf list erlang
2014-11-30 06:46:11 -07:00
```
#### List all available versions
2014-11-30 20:32:14 -07:00
```bash
2014-11-30 06:46:11 -07:00
# asdf list-all <name>
asdf list-all erlang
```
#### Use a specific version of a package
2014-11-30 20:32:14 -07:00
```bash
# asdf use <name> <version>
2014-11-30 06:46:11 -07:00
asdf use erlang 17.3
```
It writes the version to the `.versions` file in the current working directory.
2014-10-19 09:18:48 -07:00
2014-11-30 03:18:49 -07:00
2014-11-30 06:46:11 -07:00
## The `.versions` file
Add a `.versions` file to your project dir and versions of those packages will be used.
2014-10-19 09:18:48 -07:00
```
2014-11-30 06:46:11 -07:00
elixir 1.0.2
2014-10-19 09:18:48 -07:00
erlang 17.3
```
2014-11-30 06:46:11 -07:00
## Creating package sources
2014-10-19 09:18:48 -07:00
2014-11-30 03:18:49 -07:00
A package source is a git repo, with the following executable scripts
* `bin/list-all` - lists all installable versions
* `bin/install` - installs the specified version
2014-12-18 12:08:02 -07:00
* `bin/list-executables` - list executables for the version of the package
#### Options scripts
2014-11-30 06:46:11 -07:00
2014-12-18 12:08:02 -07:00
* `bin/exec-env` - whatever you want to run when a specific version is used (like set an env var?)
* `bin/uninstall` - uninstalls the specified version
2014-11-30 06:46:11 -07:00
2014-11-30 09:11:58 -07:00
### bin/list-all
2014-11-30 06:46:11 -07:00
2014-12-18 12:08:02 -07:00
Must print a string with a space-seperated list of versions. Example output would be the following:
```
1.0.1 1.0.2 1.3.0 1.4
```
2014-11-30 06:46:11 -07:00
2014-11-30 09:11:58 -07:00
### bin/install
2014-11-30 06:46:11 -07:00
This script should install the package. It will be passed the following command-line args (in order).
* *install type* - "version", "tag", "commit"
* *version* - this is the version or commit sha or the tag name that should be installed (use the first argument to figure out what to do).
* *install path* - the dir where the it *should* be installed
**Any other args that comes after this is whatever the user passes to the install command**. Feel free to use them in whatever way you think is appropriate.
2014-12-18 12:08:02 -07:00
These scripts are run when `list-all`, `install`, `uninstall` or `exec-env` commands are run. You can set or unset env vars and do whatever you need.
2014-11-30 06:46:11 -07:00
2014-12-18 12:08:02 -07:00
### bin/list-executables
2014-11-30 06:46:11 -07:00
2014-12-18 12:08:02 -07:00
Must print a string with a space-seperated list of paths to executables. The paths must be relative to the install path passed. Example output would be:
```
bin/abc bin/xyz scripts/jkl
```
2014-11-30 06:46:11 -07:00
2014-12-18 12:08:02 -07:00
### bin/exec-env
2014-11-30 06:46:11 -07:00
Will be passed the following args
* *install type*
* *version*
2014-12-18 12:08:02 -07:00
Must print a string with space-seperated list of env vars to set. Example output would be
### bin/uninstall
Uninstalls a command. Same args as the `bin/install` script.
```
FOO=123 BAR=xyz BAZ=example
```
2014-11-30 06:46:11 -07:00
## Credits
2014-10-19 09:18:48 -07:00
2014-11-30 06:46:11 -07:00
Me ([@HashNuke](http://github.com/HashNuke)), High-fever, cold, cough
2014-10-19 09:18:48 -07:00
2014-11-30 06:46:11 -07:00
Copyright 2014 to the end of time