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

Add specifying "latest" as lua/luajit/luarocks version #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions completions/_luaver
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ _luaver_install()
local -a lua_versions
if _cache_invalid lua_versions || ! _retrieve_cache lua_versions
then
lua_versions=($(_luaver_download 'https://www.lua.org/ftp/' | sed -n -e 's/.*lua\-\(5\.[0-9]\.[0-9]\)\.tar\.gz.*/\1/gp'))
lua_versions=($(_luaver_download 'https://www.lua.org/ftp/' | sed -n -e 's/.*lua\-\(5\.[0-9]\.[0-9]\)\.tar\.gz.*/\1/gp') 'latest')

_store_cache lua_versions lua_versions
fi
Expand All @@ -28,7 +28,7 @@ _luaver_install-luajit()
local -a luajit_versions
if _cache_invalid luajit_versions || ! _retrieve_cache luajit_versions
then
luajit_versions=($(_luaver_download "http://luajit.org/download.html" | awk '/MD5 Checksums/,/<\/pre/ { print }' | sed -n -e 's/.*LuaJIT-\(.*\)\.tar\.gz.*/\1/gp'))
luajit_versions=($(_luaver_download "http://luajit.org/download.html" | awk '/MD5 Checksums/,/<\/pre/ { print }' | sed -n -e 's/.*LuaJIT-\(.*\)\.tar\.gz.*/\1/gp') 'latest')

_store_cache luajit_versions luajit_versions
fi
Expand All @@ -40,7 +40,7 @@ _luaver_install-luarocks()
local -a luarocks_versions
if _cache_invalid luarocks_versions || ! _retrieve_cache luarocks_versions
then
luarocks_versions=($(_luaver_download 'http://luarocks.github.io/luarocks/releases/releases.json' | sed -n -e 's/.*luarocks-\(.*\)\.tar\.gz.*/\1/gp'))
luarocks_versions=($(_luaver_download 'http://luarocks.github.io/luarocks/releases/releases.json' | sed -n -e 's/.*luarocks-\(.*\)\.tar\.gz.*/\1/gp') 'latest')

_store_cache luarocks_versions luarocks_versions
fi
Expand All @@ -51,19 +51,19 @@ _luaver()
{
local -a _1st_arguments
_1st_arguments=(
'install:Install the given lua version'
'install:Install the given lua version (can be "latest")'
'use:Switch to the given lua version'
'set-default:Set the given version as default for lua'
'unset-default:Unset the default lua version'
'uninstall:Uninstall the given lua version'
'list:List installed lua versions'
'install-luajit:Install the given luajit version'
'install-luajit:Install the given luajit version (can be "latest")'
'use-luajit:Switch to the given luajit version'
'set-default-luajit:Set the given version as default for luajit'
'unset-default-luajit:Unset the default luajit version'
'uninstall-luajit:Uninstall the given luajit version'
'list-luajit:List installed luajit versions'
'install-luarocks:Install the given luarocks version'
'install-luarocks:Install the given luarocks version (can be "latest")'
'use-luarocks:Switch to the given luarocks version'
'set-default-luarocks:Set the given version as default for luarocks'
'unset-default-luarocks:Unset the default luarocks version'
Expand Down
6 changes: 3 additions & 3 deletions completions/luaver.bash
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ _luaver()
declare -a _luaver_lua_versions
if [ -z "$_luaver_lua_versions" ]
then
_luaver_lua_versions=($(_luaver_download 'https://www.lua.org/ftp/' | sed -n -e 's/.*lua\-\(5\.[0-9]\.[0-9]\)\.tar\.gz.*/\1/gp'))
_luaver_lua_versions=($(_luaver_download 'https://www.lua.org/ftp/' | sed -n -e 's/.*lua\-\(5\.[0-9]\.[0-9]\)\.tar\.gz.*/\1/gp') 'latest')
fi
opts=(${_luaver_lua_versions[@]})
;;
install-luajit )
if [ -z "$_luaver_luajit_versions" ]
then
_luaver_luajit_versions=($(_luaver_download "http://luajit.org/download.html" | awk '/MD5 Checksums/,/<\/pre/ { print }' | sed -n -e 's/.*LuaJIT-\(.*\)\.tar\.gz.*/\1/gp'))
_luaver_luajit_versions=($(_luaver_download "http://luajit.org/download.html" | awk '/MD5 Checksums/,/<\/pre/ { print }' | sed -n -e 's/.*LuaJIT-\(.*\)\.tar\.gz.*/\1/gp') 'latest')
fi
opts=(${_luaver_luajit_versions[@]})
;;
install-luarocks )
if [ -z "$_luaver_luarocks_versions" ]
then
_luaver_luarocks_versions=($(_luaver_download 'http://luarocks.github.io/luarocks/releases/releases.json' | sed -n -e 's/.*luarocks-\(.*\)\.tar\.gz.*/\1/gp'))
_luaver_luarocks_versions=($(_luaver_download 'http://luarocks.github.io/luarocks/releases/releases.json' | sed -n -e 's/.*luarocks-\(.*\)\.tar\.gz.*/\1/gp') 'latest')
fi
opts=(${_luaver_luarocks_versions[@]})
;;
Expand Down
12 changes: 9 additions & 3 deletions luaver
Original file line number Diff line number Diff line change
Expand Up @@ -380,19 +380,19 @@ __luaver_usage()
__luaver_version
__luaver_print_formatted "Usage:\n"
__luaver_print_formatted " luaver help Displays this message"
__luaver_print_formatted " luaver install <version> Installs lua-<version>"
__luaver_print_formatted " luaver install <version> Installs lua-<version> (can be \"latest\")"
__luaver_print_formatted " luaver use <version> Switches to lua-<version>"
__luaver_print_formatted " luaver set-default <version> Sets <version> as default for lua"
__luaver_print_formatted " luaver unset-default Unsets the default lua version"
__luaver_print_formatted " luaver uninstall <version> Uninstalls lua-<version>"
__luaver_print_formatted " luaver list [-r] Lists installed lua versions"
__luaver_print_formatted " luaver list [-r] Lists installed lua versions (can be \"latest\")"
__luaver_print_formatted " luaver install-luajit <version> Installs luajit-<version>"
__luaver_print_formatted " luaver use-luajit <version> Switches to luajit-<version>"
__luaver_print_formatted " luaver set-default-luajit <version> Sets <version> as default for luajit"
__luaver_print_formatted " luaver unset-default-luajit Unsets the default luajit version"
__luaver_print_formatted " luaver uninstall-luajit <version> Uninstalls luajit-<version>"
__luaver_print_formatted " luaver list-luajit [-r] Lists installed luajit versions"
__luaver_print_formatted " luaver install-luarocks <version> Installs luarocks<version>"
__luaver_print_formatted " luaver install-luarocks <version> Installs luarocks<version> (can be \"latest\")"
__luaver_print_formatted " luaver use-luarocks <version> Switches to luarocks-<version>"
__luaver_print_formatted " luaver set-default-luarocks <version> Sets <version> as default for luarocks"
__luaver_print_formatted " luaver unset-default-luarocks Unsets the default luarocks version"
Expand All @@ -411,6 +411,7 @@ __luaver_usage()
__luaver_install_lua()
{
local version=$1
[ 'xlatest' = "x${version}" ] && version="$(__luaver_list_lua -r | grep -v '^latest$' | tail -n 1)"
local lua_dir_name="lua-${version}"
local archive_name="${lua_dir_name}.tar.gz"
local url="http://www.lua.org/ftp/${archive_name}"
Expand Down Expand Up @@ -533,6 +534,7 @@ __luaver_list_lua()
'awk' 'match($0, /lua-5\.[0-9]+(\.[0-9]+)?/) { print substr($0, RSTART + 4, RLENGTH - 4) }' |
# Sort semver
'sort' -t . -k 1,1n -k 2,2n -k 3,3n
printf 'latest\n'
else
__luaver_print "Installed versions: (currently $(__luaver_get_current_lua_version || echo none))"
'find' "${__luaver_LUA_DIR}" -name '*.*' -prune | 'awk' -F/ '{ print $NF }'
Expand All @@ -542,6 +544,7 @@ __luaver_list_lua()
__luaver_install_luajit()
{
local version=$1
[ 'xlatest' = "x${version}" ] && version="$(__luaver_list_luajit -r | grep -v '^latest$' | tail -n 1)"
local luajit_dir_name="LuaJIT-${version}"
local archive_name="${luajit_dir_name}.tar.gz"
local url="http://luajit.org/download/${archive_name}"
Expand Down Expand Up @@ -646,6 +649,7 @@ __luaver_list_luajit()
'sed' -e s/-beta/.beta./ |
'sort' -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4r -k 5,5n -r |
'sed' -e s/.beta./-beta/
printf 'latest\n'
else
__luaver_print "Installed versions: (currently $(__luaver_get_current_luajit_version || echo none))"
'find' "${__luaver_LUAJIT_DIR}" -name '*.*' -prune | 'awk' -F/ '{ print $NF }'
Expand All @@ -664,6 +668,7 @@ __luaver_install_luarocks()
lua_version_short=$(__luaver_get_current_lua_version_short)

local version=$1
[ 'xlatest' = "x${version}" ] && version="$(__luaver_list_luarocks -r | grep -v '^latest$' | tail -n 1)"
local luarocks_dir_name="luarocks-${version}"
local archive_name="${luarocks_dir_name}.tar.gz"
local url="http://luarocks.org/releases/${archive_name}"
Expand Down Expand Up @@ -778,6 +783,7 @@ __luaver_list_luarocks()
'awk' 'match($0, /"[0-9]+\.[0-9]\.[0-9]"/) { print substr($0, RSTART + 1, RLENGTH - 2) } ' |
# Sort semver
'sort' -t . -k 1,1n -k 2,2n -k 3,3n
printf 'latest\n'
else
__luaver_print "Installed versions: (currently $(__luaver_get_current_luarocks_version || echo none) in lua $(__luaver_get_lua_version_by_current_luarocks || echo none))"
'find' "${__luaver_LUAROCKS_DIR}" -name '*.*' -prune | 'awk' -F/ '{ print $NF }' | 'awk' -F_ '{ print $1 "\tlua:" $2}'
Expand Down