use new bootstrap + webinstall approach
[webi-installers/.git] / pathman / pathman.bash
index 7de2693a9918b85e6d04243925189ab71fa704dc..4b9e53876d0ebf61996eef4e3ace504031b01ec4 100644 (file)
@@ -4,19 +4,21 @@
 # homepage: https://git.rootprojects.org/root/pathman
 # tagline: cross-platform PATH management for bash, zsh, fish, cmd.exe, and PowerShell
 # description: |
-#   Works with
-#   - Mac, Windows, Linux
-#   - Bash, Zsh, Fish
-#   - Command, Powershell
+#   Manages PATH on various OSes and shells
+#     - Mac, Windows, Linux
+#     - Bash, Zsh, Fish
+#     - Command, Powershell
 # examples: |
 #   ```bash
 #   pathman add ~/.local/bin
 #   ```
 #   <br/>
+#
 #   ```bash
 #   pathman remove ~/.local/bin
 #   ```
 #   <br/>
+#
 #   ```bash
 #   pathman list
 #   ```
 set -e
 set -u
 
-# Get arch envs, etc
-my_url="https://rootprojects.org/pathman/dist/$(uname -s)/$(uname -m)/pathman"
-curl -fL "$my_url" -o pathman
-echo ""
-# Make executable
-chmod +x ./pathman
-# Move to ~/.local/bin
-mkdir -p ~/.local/bin
-mv ./pathman ~/.local/bin
-
 # Test if in PATH
 set +e
 my_pathman=$(command -v pathman)
 set -e
 if [ -n "$my_pathman" ]; then
+    # TODO test pathman version
+    # if [ "$WEBI_VERSION" == "$(pathman version | cut -d ' ' -f2)" ]; then
        if [ "$my_pathman" != "$HOME/.local/bin/pathman" ]; then
                echo "a pathman installation (which make take precedence) exists at:"
                echo "    $my_pathman"
                echo ""
        fi
+    echo "pathman already installed"
+    exit 0
 fi
 
+# TODO use webi_download via releases.js
+webi_download "https://rootprojects.org/pathman/dist/$(uname -s)/$(uname -m)/pathman" "$HOME/.local/bin/pathman"
+
+# TODO use webi_extract
+chmod +x "$HOME/.local/bin/pathman"
+
 # add to ~/.local/bin to PATH even if pathman is elsewhere
 # TODO pathman needs silent option and debug output (quiet "already exists" output)
-~/.local/bin/pathman add ~/.local/bin # > /dev/null 2> /dev/null
+"$HOME/.local/bin/pathman" add ~/.local/bin # > /dev/null 2> /dev/null
 # TODO inform user to add to path, apart from pathman?