aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2014-01-21 22:53:28 +0100
committerGravatar Tom Willemse2014-01-21 22:53:28 +0100
commit17ac6369162579208b037a542852f11d824ce48c (patch)
treec742ade9dc8cd2f57d80cc9e26ae212cbd4d5724
parent0ef2e8a7dfb384ffc727f7a307c1ef51f9f93b47 (diff)
downloadsti-17ac6369162579208b037a542852f11d824ce48c.tar.gz
sti-17ac6369162579208b037a542852f11d824ce48c.zip
Add reinit command
-rwxr-xr-xsti51
1 files 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 <command>' 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