From 1f2373bab39ca6bc6cc6d4b07ae91f2efab09055 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Thu, 3 Oct 2013 23:19:28 +0100 Subject: [PATCH] Initial setup for the "run mode" concept --- src/bin/dotify | 1 + src/lib/dotify-clean.sh | 5 +++++ src/lib/dotify-install.sh | 7 +------ src/lib/dotify-uninstall.sh | 5 +++++ src/lib/internals/execute-dotfile.sh | 9 +++++++++ 5 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 src/lib/dotify-clean.sh create mode 100644 src/lib/dotify-uninstall.sh create mode 100644 src/lib/internals/execute-dotfile.sh diff --git a/src/bin/dotify b/src/bin/dotify index cbde7a7..6a94e38 100755 --- a/src/bin/dotify +++ b/src/bin/dotify @@ -40,6 +40,7 @@ source "../lib/trim.sh" source "../lib/internals/compile-dotfile.sh" source "../lib/internals/create-symlink.sh" +source "../lib/internals/execute-dotfile.sh" source "../lib/internals/locate-dotfile.sh" source "../lib/internals/locate-target.sh" source "../lib/internals/parse-dotfile-options.sh" diff --git a/src/lib/dotify-clean.sh b/src/lib/dotify-clean.sh new file mode 100644 index 0000000..23580a2 --- /dev/null +++ b/src/lib/dotify-clean.sh @@ -0,0 +1,5 @@ +dotify-clean() { + DOTIFY_RUN_MODE="clean" + execute-dotfile + return $? +} diff --git a/src/lib/dotify-install.sh b/src/lib/dotify-install.sh index 8cef231..9ff3b8a 100644 --- a/src/lib/dotify-install.sh +++ b/src/lib/dotify-install.sh @@ -1,10 +1,5 @@ dotify-install() { - locate-dotfile - if [ -n "$?" ]; then return 1; fi - - locate-target - if [ -n "$?" ]; then return 1; fi - + DOTIFY_RUN_MODE="install" execute-dotfile return $? } diff --git a/src/lib/dotify-uninstall.sh b/src/lib/dotify-uninstall.sh new file mode 100644 index 0000000..e845e56 --- /dev/null +++ b/src/lib/dotify-uninstall.sh @@ -0,0 +1,5 @@ +dotify-uninstall() { + DOTIFY_RUN_MODE="uninstall" + execute-dotfile + return $? +} diff --git a/src/lib/internals/execute-dotfile.sh b/src/lib/internals/execute-dotfile.sh new file mode 100644 index 0000000..051e721 --- /dev/null +++ b/src/lib/internals/execute-dotfile.sh @@ -0,0 +1,9 @@ +execute-dotfile() { + local dotfile_source="$(dotify-compile)" + + locate-target + if [ "$?" != "0" ]; then return 1; fi + + echo "$dotfile_source" + return $? +}