From 17ac6369162579208b037a542852f11d824ce48c Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 21 Jan 2014 22:53:28 +0100 Subject: Add reinit command --- sti | 51 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/sti b/sti index 092fd0b..c9e2a99 100755 --- a/sti +++ b/sti @@ -24,6 +24,7 @@ function cmd_help echo "Commands include: " echo " help Show this help message" echo " install Install a tool from a git repository" + echo " reinit Retry installing the executables of a tool" echo " remove Remove an installed tool" echo echo "You can use \`$xname help ' to get more \ @@ -31,6 +32,43 @@ information about a command." | fold fi } +function help_reinit () +{ + local xname="$(basename 0)" + + echo "Usage: ${xname} reinit TOOL" + echo + echo "TOOL should be the name of a tool installed previously with \ +\`${xname} install'. This name is the base name of the URL used to \ +install the tool, with the \`.git' suffix removed." | fold + echo + echo "Each executable file found in the tool's directory is checked \ +to see if it exists in ${bin_home}, it reports whether it is already \ +installed or doesn't belong to the tool. If it doesn't exist a symlink \ +is created in ${bin_home}." | fold +} + +function cmd_reinit () +{ + local tool_home="${data_home}/tools/$1" + + if [[ -d "$tool_home" ]]; then + for exe in $(find-executables "$tool_home"); do + local executable_name=$(basename "$exe") + local destination="${bin_home}/${executable_name}" + + if [[ ! -e "$destination" ]]; then + ln -s "$exe" "$destination" + elif [[ "$(readlink $destination)" == "$exe" ]]; then + echo "Executable ${executable_name} already installed" + else + echo "Executable ${executable_name} already exists in \ +${bin_home}" + fi + done + fi +} + function help_install () { local xname="$(basename $0)" @@ -52,18 +90,7 @@ function cmd_install () if [[ ! -d "$tool_home" ]]; then git clone $1 "$tool_home" - - for exe in $(find-executables "$tool_home"); do - local executable_name=$(basename "$exe") - local destination="${bin_home}/${executable_name}" - - if [[ ! -e "$destination" ]]; then - ln -s "$exe" "$destination" - else - echo "Executable ${executable_name} already exists in \ -${bin_home}" - fi - done + cmd_reinit "$tool_name" else echo "Tool ${tool_name} already installed" exit 2 -- cgit v1.2.3-54-g00ecf