Skip to content

Commit

Permalink
direcotory resource has default values, supports create and delete
Browse files Browse the repository at this point in the history
action
  • Loading branch information
Tom Bombadil committed Oct 6, 2012
1 parent 01269fe commit d2d14cf
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions bin/_poop
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,17 +10,37 @@ function directory {
} }


function do_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 # since install -d recursively creates directories, check for intermediate
# directories manually when recursion is not desired # directories manually when recursion is not desired
if [[ -z "$_poop_recursive" ]]; then if [[ "$_poop_recursive" = false ]]; then
local dname="$(dirname "${_poop_path:-${_poop_name}}")" local dname="$(dirname "${_poop_path}")"
if [[ ! -d "$dname" ]]; then 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 exit 1
fi fi
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 { function mode {
Expand All @@ -47,6 +67,7 @@ function end {
eval "do_${_poop_resource}" eval "do_${_poop_resource}"


_poop_name= _poop_name=
_poop_action=
_poop_mode= _poop_mode=
_poop_owner= _poop_owner=
_poop_group= _poop_group=
Expand Down

0 comments on commit d2d14cf

Please sign in to comment.