2 Sitoutukset 53bbf4406c ... c3dee5c609

Tekijä SHA1 Viesti Päivämäärä
  Daniel Sheffield c3dee5c609 rename dot to ․ but keep dot as a symlink to ․ 1 kuukausi sitten
  Daniel Sheffield 748bc638f2 add hints on missing args 1 kuukausi sitten
3 muutettua tiedostoa jossa 88 lisäystä ja 82 poistoa
  1. 0 82
      dot
  2. 1 0
      dot
  3. 87 0
     

+ 0 - 82
dot

@@ -1,82 +0,0 @@
-#!/bin/bash
-set -euo pipefail
-
-# shellcheck disable=SC2034
-action="$1"
-package="$2"
-target="${3:-}"
-
-if [ "${DEBUG:=}" ]
-then
-    stow="stow --simulate --verbose=${DEBUG}"
-else
-    stow="stow"
-fi
-
-DOTFILES_DIR="${DOTFILES_DIR:=}"
-[ "$DOTFILES_DIR" ] || DOTFILES_DIR=$(pwd)
-
-action_to_arg(){
-case "$1" in
-    "remove") echo --delete;;
-    "update") echo --restow;;
-    "apply" ) echo --stow;;
-    *       ) ;;
-esac
-}
-
-target_to_dest(){
-case "$1" in
-    "user"  ) echo "$HOME";;
-    "system") echo /;;
-    *       ) ;;
-esac
-}
-
-_stow(){
-    stow_dir="$1"
-    stow_target_dir="$2"
-    stow_action="$3"
-    stow_package="$4"
-    (
-        [ "$DEBUG" ] && set -x
-        $stow --no-folding -d "${stow_dir}" -t "${stow_target_dir}" "${stow_action}" "${stow_package}"
-    )
-}
-
-action=$(action_to_arg "$action")
-
-[ "$action" ] || {
-    echo "No such action: $1"
-    exit
-}
-
-if [ "$target" ]
-then
-    if  [ -d "${DOTFILES_DIR}/${package}/${target}" ]
-    then
-        dest=$(target_to_dest "$target")
-        _stow "${DOTFILES_DIR}/${package}" "${dest}" "${action}" "${target}"
-    else
-        [ "$target" == "user" ] || {
-            echo "Target '$target' does not exist for package '$package'"
-            exit 1
-        }
-        dest=$(target_to_dest "user")
-        _stow "${DOTFILES_DIR}" "${dest}" "${action}" "${package}"
-    fi
-else
-    any=false
-    for target in user system;
-    do
-        [ -d "${DOTFILES_DIR}/${package}/${target}" ] || continue
-        any=true
-        dest=$(target_to_dest "$target")
-        _stow "${DOTFILES_DIR}/${package}" "${dest}" "${action}" "${target}"
-    done
-    if ! "$any"
-    then
-        dest=$(target_to_dest "user")
-        _stow "${DOTFILES_DIR}" "${dest}" "${action}" "${package}"
-    fi
-fi

+ 1 - 0
dot

@@ -0,0 +1 @@
+․

+ 87 - 0

@@ -0,0 +1,87 @@
+#!/bin/bash
+set -euo pipefail
+
+DOTFILES_DIR="${DOTFILES_DIR:=}"
+[ "$DOTFILES_DIR" ] || DOTFILES_DIR=$(pwd)
+
+readarray -d $'\0' -t pkgs < <(find "$DOTFILES_DIR" -maxdepth 1 -mindepth 1 -follow -type d \! -name '.*' -printf '%f\0')
+pkgs=${|
+    local IFS=,; REPLY="${pkgs[*]}";
+}
+
+action="${1:?action must be apply, update, or remove}"
+package="${2:?package must be one of $pkgs}"
+target="${3:-}"
+
+if [ "${DEBUG:=}" ]
+then
+    stow="stow --simulate --verbose=${DEBUG}"
+else
+    stow="stow"
+fi
+
+
+action_to_arg(){
+case "$1" in
+    "remove") echo --delete;;
+    "update") echo --restow;;
+    "apply" ) echo --stow;;
+    *       ) ;;
+esac
+}
+
+target_to_dest(){
+case "$1" in
+    "user"  ) echo "$HOME";;
+    "system") echo /;;
+    *       ) ;;
+esac
+}
+
+_stow(){
+    stow_dir="$1"
+    stow_target_dir="$2"
+    stow_action="$3"
+    stow_package="$4"
+    (
+        [ "$DEBUG" ] && set -x
+        $stow --no-folding -d "${stow_dir}" -t "${stow_target_dir}" "${stow_action}" "${stow_package}"
+    )
+}
+
+action=$(action_to_arg "$action")
+
+[ "$action" ] || {
+    echo "No such action: $1"
+    exit
+}
+
+if [ "$target" ]
+then
+    if  [ -d "${DOTFILES_DIR}/${package}/${target}" ]
+    then
+        dest=$(target_to_dest "$target")
+        _stow "${DOTFILES_DIR}/${package}" "${dest}" "${action}" "${target}"
+    else
+        [ "$target" == "user" ] || {
+            echo "Target '$target' does not exist for package '$package'"
+            exit 1
+        }
+        dest=$(target_to_dest "user")
+        _stow "${DOTFILES_DIR}" "${dest}" "${action}" "${package}"
+    fi
+else
+    any=false
+    for target in user system;
+    do
+        [ -d "${DOTFILES_DIR}/${package}/${target}" ] || continue
+        any=true
+        dest=$(target_to_dest "$target")
+        _stow "${DOTFILES_DIR}/${package}" "${dest}" "${action}" "${target}"
+    done
+    if ! "$any"
+    then
+        dest=$(target_to_dest "user")
+        _stow "${DOTFILES_DIR}" "${dest}" "${action}" "${package}"
+    fi
+fi