Permalink
Browse files

direcotory resource has default values, supports create and delete

action
  • Loading branch information...
1 parent 01269fe commit d2d14cfd492aa81d8b0d6273452fa20ee182f7df @defn defn committed Oct 6, 2012
Showing with 25 additions and 4 deletions.
  1. +25 −4 bin/_poop
View
@@ -10,17 +10,37 @@ function directory {
}
function do_directory {
+ : ${_poop_action:=create}
+ : ${_poop_path:=${_poop_name}}
+ : ${_poop_recursive:=false}
+
+ eval "do_${_poop_resource}_${_poop_action}"
+}
+
+function do_directory_create {
# since install -d recursively creates directories, check for intermediate
# directories manually when recursion is not desired
- if [[ -z "$_poop_recursive" ]]; then
- local dname="$(dirname "${_poop_path:-${_poop_name}}")"
+ if [[ "$_poop_recursive" = false ]]; then
+ local dname="$(dirname "${_poop_path}")"
if [[ ! -d "$dname" ]]; then
- logger_fatal "while creating ${_poop_path:-${_poop_name}}, $dname is not a directory"
+ logger_fatal "while creating ${_poop_path}, $dname is not a directory"
exit 1
fi
fi
- install -v -d $(install_options)"${_poop_path:-${_poop_name}}"
+ install -v -d $(install_options)"${_poop_path}"
+}
+
+function do_directory_delete {
+ if [[ "$_poop_recursive" = false ]]; then
+ rm -vd "${_poop_path}"
+ else
+ rm -vrf "${_poop_path}"
+ fi
+}
+
+function action {
+ _poop_action="$1"; shift
}
function mode {
@@ -47,6 +67,7 @@ function end {
eval "do_${_poop_resource}"
_poop_name=
+ _poop_action=
_poop_mode=
_poop_owner=
_poop_group=

0 comments on commit d2d14cf

Please sign in to comment.