forked from ungleich-public/cdist
add messaging support for __key_value
Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
parent
19f6126a0f
commit
0a98abbffa
2 changed files with 13 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
# 2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2012-2014 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
@ -42,12 +42,14 @@ cp -p "$file" "\$tmpfile"
|
|||
sed '/^$key\($delimiter\+\)/d' "$file" > "\$tmpfile"
|
||||
mv -f "\$tmpfile" "$file"
|
||||
DONE
|
||||
echo "remove" >> "$__messages_out"
|
||||
;;
|
||||
present)
|
||||
case "$state_is" in
|
||||
absent)
|
||||
# add new key and value
|
||||
printf 'echo "%s%s%s" >> "%s"' "$key" "$delimiter" "$value_escaped" "$file"
|
||||
echo "add" >> "$__messages_out"
|
||||
;;
|
||||
wrongvalue)
|
||||
# change exisiting value
|
||||
|
@ -58,6 +60,7 @@ cp -p "$file" "\$tmpfile"
|
|||
sed "s|^$key\($delimiter\+\).*|$key\\1$value_escaped|" "$file" > "\$tmpfile"
|
||||
mv -f "\$tmpfile" "$file"
|
||||
DONE
|
||||
echo "changevalue" >> "$__messages_out"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown explorer state: $state_is" >&2
|
||||
|
|
|
@ -32,6 +32,15 @@ key::
|
|||
value::
|
||||
The value for the key. Optional if state=absent, required otherwise.
|
||||
|
||||
MESSAGES
|
||||
--------
|
||||
create::
|
||||
Added key and value
|
||||
change::
|
||||
Changed value of existing key
|
||||
remove::
|
||||
Removed existing key and value
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
|
Loading…
Reference in a new issue