add push option for syncing
This commit is contained in:
parent
fef7d5adfc
commit
dfe11f6d03
54
t.sh
54
t.sh
|
@ -4,7 +4,6 @@
|
||||||
trap "exit 1" TERM
|
trap "exit 1" TERM
|
||||||
export MYPID=$$
|
export MYPID=$$
|
||||||
|
|
||||||
|
|
||||||
. ${HOME}/code/bashtools/bashtools.sh
|
. ${HOME}/code/bashtools/bashtools.sh
|
||||||
if [[ -z $HAVE_BASHTOOLS ]]; then
|
if [[ -z $HAVE_BASHTOOLS ]]; then
|
||||||
echo "ERROR: bashtools not installed download from https://git.nethack.net/rob/bashtools" >/dev/stderr
|
echo "ERROR: bashtools not installed download from https://git.nethack.net/rob/bashtools" >/dev/stderr
|
||||||
|
@ -1474,14 +1473,32 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
function tasksync() {
|
function tasksync() {
|
||||||
local res upcount downcount noun
|
local res upcount downcount noun="Sync" mode="sync"
|
||||||
|
|
||||||
if [[ $1 == "-a" ]]; then
|
while [[ $# -ge 1 ]]; do
|
||||||
noun="Auto-sync"
|
if [[ $1 == "-a" ]]; then
|
||||||
else
|
noun="Auto-sync"
|
||||||
noun="Sync"
|
elif [[ $1 == "push" ]]; then
|
||||||
|
mode="push"
|
||||||
|
noun="Push"
|
||||||
|
elif [[ $1 == "pull" ]]; then
|
||||||
|
mode="pull"
|
||||||
|
noun="Pull"
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
notify "${noun}ing tasks"
|
||||||
|
|
||||||
|
# adjust conflict resolution
|
||||||
|
## remove existing setting
|
||||||
|
sed -i '/^conflict/ s/^/#/' $vdirsyncconfig
|
||||||
|
## add new one
|
||||||
|
if [[ $mode == "push" ]]; then
|
||||||
|
sed -i '/conflict.*a wins/ s/^#\+//' $vdirsyncconfig
|
||||||
|
elif [[ $mode == "pull" ]]; then
|
||||||
|
sed -i '/conflict.*b wins/ s/^#\+//' $vdirsyncconfig
|
||||||
fi
|
fi
|
||||||
notify "Syncing tasks"
|
|
||||||
res=$(${VDIRSYNCER} sync 2>&1)
|
res=$(${VDIRSYNCER} sync 2>&1)
|
||||||
rv=$?
|
rv=$?
|
||||||
[[ $rv -eq 0 ]] && ok || fail
|
[[ $rv -eq 0 ]] && ok || fail
|
||||||
|
@ -1503,9 +1520,24 @@ function tasksync() {
|
||||||
inform "$noun complete - $upcount change$upess pushed, $downcount change$downess pulled."
|
inform "$noun complete - $upcount change$upess pushed, $downcount change$downess pulled."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
error "$noun failed. Output:"
|
errmsg="$noun failed."
|
||||||
echo "$res" | sed -e 's/^/ /'
|
if [[ $mode == "sync" ]]; then
|
||||||
|
errmsg="${errmsg} Try ^bt push^p or ^bt pull^p."
|
||||||
|
fi
|
||||||
|
error "$errmsg"
|
||||||
|
if [[ $mode != "sync" ]]; then
|
||||||
|
cecho -s "$RED" "^bDetails:^p"
|
||||||
|
cecho -s "$RED" "$res" | sed -e 's/^/ /'
|
||||||
|
echo
|
||||||
|
cecho -s "$RED" "^bConflict settings:^p"
|
||||||
|
errmsg=$(grep "conflict" $vdirsyncconfig 2>&1)
|
||||||
|
cecho -s "$YELLOW" "$errmsg" | sed -e 's/^/ /'
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
## remove conflict setting again
|
||||||
|
sed -i '/^conflict/ s/^/#/' $vdirsyncconfig
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getcals() { # countvar arrayvar
|
function getcals() { # countvar arrayvar
|
||||||
|
@ -1634,6 +1666,7 @@ addcmd "note" "note <id> <notes>" "Change notes for given task" "note|desc|descr
|
||||||
addcmd "tag" "tag <id> <tag>" "Add a tag to the given task" "tag|t"
|
addcmd "tag" "tag <id> <tag>" "Add a tag to the given task" "tag|t"
|
||||||
addcmd "untag" "untag <id> <tag>" "Remove a tag from the given task" "untag|ut"
|
addcmd "untag" "untag <id> <tag>" "Remove a tag from the given task" "untag|ut"
|
||||||
addcmd "sync" "sync" "Sync tasks using vdirsyncer" "sync"
|
addcmd "sync" "sync" "Sync tasks using vdirsyncer" "sync"
|
||||||
|
addcmd "push" "push" "Push all tasks to server" "push"
|
||||||
addcmd "view" "view <id>" "Show detailed info for given task" "v|view|info|vcal" PASSIVE
|
addcmd "view" "view <id>" "Show detailed info for given task" "v|view|info|vcal" PASSIVE
|
||||||
addcmd "showcals" "showcals" "List available calendars" "cals|showcals|cls" PASSIVE
|
addcmd "showcals" "showcals" "List available calendars" "cals|showcals|cls" PASSIVE
|
||||||
addcmd "setcal" "setcal" "Set the default calendar." "setcal|sc"
|
addcmd "setcal" "setcal" "Set the default calendar." "setcal|sc"
|
||||||
|
@ -1745,6 +1778,9 @@ fi
|
||||||
if [[ $mode == "sync" ]]; then
|
if [[ $mode == "sync" ]]; then
|
||||||
tasksync
|
tasksync
|
||||||
exit $rv
|
exit $rv
|
||||||
|
elif [[ $mode == "push" ]]; then
|
||||||
|
tasksync push
|
||||||
|
exit $rv
|
||||||
fi
|
fi
|
||||||
|
|
||||||
notify "Processing"
|
notify "Processing"
|
||||||
|
|
Loading…
Reference in New Issue