Fix up functions; get list working

This commit is contained in:
Akash Manohar J 2014-11-29 16:54:02 +05:30
parent 12b420b908
commit 643d3419cb

123
lib/asdf.sh Normal file → Executable file
View File

@ -6,122 +6,47 @@
ASDF_DIR=$(dirname $0)
asdf_version () {
asdf_version() {
echo "0.1"
}
run_command () {
if [ $1 = "--version" ]
asdf_dir() {
echo $(dirname $(dirname $0))
}
check_and_run() {
if [ "$1" = "$2" ]
then
echo $(asdf_version)
$($3 ${@:4})
exit 0
fi
}
if [ $1 = "install" ]
then
install_command
exit 0
fi
run_command() {
check_and_run "--version" $1 asdf_version "${@:2}"
check_and_run "list" $1 list_command "${@:2}"
# if [ "$1" = "list" ]
# then
# list_command "$@"
# exit 0
# fi
if [ $1 = "uninstall" ]
then
uninstall_command
exit 0
fi
if [ $1 = "list" ]
then
list_command
exit 0
fi
if [ $1 = "use" ]
then
use_command
exit 0
fi
if [ $1 = "source" ]
then
source_command
exit 0
fi
help_all
}
# # install <package> <version>
install_command() {
echo "TODO install"
list_command() {
echo ./$(asdf_dir)/sources/$1/list
}
# uninstall_command <package> <version>
uninstall_command() {
echo "TODO uninstall"
help_all() {
echo "display help message"
}
# # list
# list_packages_command() {
# }
#
#
# # list <package>
# list_all_versions_command() {
# }
#
#
# # list <package>
# list_installed_versions_command() {
# }
#
#
# # add <package> <source>
# # source can be username/repo got GitHub or full git url
# add_package_command() {
# }
#
#
# # use <package> <version>
# use_command() {
# }
# --help or help
# help_command {
# }
#### Private functions
# read_action_script() {
#
# }
#
# run_install_script() {
#
# }
#
# run_uninstall_script() {
#
# }
clone_git_repo() {
git clone $2 $ASDF_DIR/sources/$1
}
clone_github_repo() {
git clone https://github.com/$2 $ASDF_DIR/sources/$1
}
# check if package source dir has proper format. if no delete it
# verify_package_source() {
#
# }
run_command "$@"