From c30934c95e4d39753c1c034a5af198a8e3f27154 Mon Sep 17 00:00:00 2001 From: Karel Balej Date: Sat, 27 Aug 2022 13:15:01 +0200 Subject: [PATCH] todoman: add completions, edit dependencies --- srcpkgs/todoman/patches/zsh_completion.patch | 86 ++++++++++++++++++++ srcpkgs/todoman/template | 7 +- 2 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 srcpkgs/todoman/patches/zsh_completion.patch diff --git a/srcpkgs/todoman/patches/zsh_completion.patch b/srcpkgs/todoman/patches/zsh_completion.patch new file mode 100644 index 000000000000..6b29b03be789 --- /dev/null +++ b/srcpkgs/todoman/patches/zsh_completion.patch @@ -0,0 +1,86 @@ +A pull request containing this patch has been submitted upstream [1]. + +[1] https://github.com/pimutils/todoman/pull/495 + +diff --git a/contrib/completion/zsh/_todo b/contrib/completion/zsh/_todo +index b9bbe8a..53976e7 100644 +--- a/contrib/completion/zsh/_todo ++++ b/contrib/completion/zsh/_todo +@@ -5,7 +5,7 @@ local common_options_help=( + '(- :)--help[Show a help message and exit]' + ) + local common_options_start=( +- {-s,--start=}'[When the task starts]:DATE:__todo_date' ++ '--start=[When the task starts]:DATE:__todo_date' + ) + local common_options_due=( + {-d,--due=}'[When the task is due]:DATE:__todo_date' +@@ -32,7 +32,7 @@ __color_mode(){ + # }}} + # {{{ general helper: set variable of path to configuration file + __todo_set_conf(){ +- todoman_configuration_file=${XDG_CONFIG_DIR:-${HOME}/.config}/todoman/todoman.conf ++ todoman_configuration_file=${XDG_CONFIG_DIR:-${HOME}/.config}/todoman/config.py + if [[ -f $todoman_configuration_file ]]; then + return 0 + else +@@ -43,7 +43,7 @@ __todo_set_conf(){ + # {{{ general helper: set variable main.path from configuration file + __todo_set_conf_path(){ + if __todo_set_conf; then +- tasks_lists_path="$(sed -n -e 's/^[^#]\s*path\s*=\s*\(.*\)$/\1/p' $todoman_configuration_file 2>/dev/null)" ++ tasks_lists_path="$(sed -n -e "s/^\\s*path\\s*=\\s*['\"]\\(.*\\)['\"]$/\\1/p" $todoman_configuration_file 2>/dev/null)" + # the eval echo is needed since the path may contain ~ which should be evalueated to $HOME + tasks_lists_dir="$(eval echo ${tasks_lists_path%/\**})" + if [[ -z "${tasks_lists_path}" || ! -d "${tasks_lists_dir}" ]]; then +@@ -59,18 +59,18 @@ __todo_set_conf_path(){ + # {{{ general helper: set variables related to date and time formats for __todo_date + __todo_set_conf_dt(){ + if __todo_set_conf; then +- date_format="$(eval echo $(sed -n -e 's/^[^#]\s*date_format\s*=\s*\(.*\)$/\1/p' $todoman_configuration_file 2>/dev/null))" +- dt_separator="$(eval echo $(sed -n -e 's/^[^#]\s*dt_separator\s*=\s*\(.*\)$/\1/p' $todoman_configuration_file 2>/dev/null))" +- time_format="$(eval echo $(sed -n -e 's/^[^#]\s*time_format\s*=\s*\(.*\)$/\1/p' $todoman_configuration_file 2>/dev/null))" ++ date_format="$(eval echo $(sed -n -e "s/^\\s*date_format\\s*=\\s*['\"]\\(.*\\)['\"]$/\\1/p" $todoman_configuration_file 2>/dev/null))" ++ dt_separator="$(eval echo $(sed -n -e "s/^\\s*dt_separator\\s*=\\s*['\"]\\(.*\\)['\"]$/\\1/p" $todoman_configuration_file 2>/dev/null))" ++ time_format="$(eval echo $(sed -n -e "s/^\\s*time_format\\s*=\\s*['\"]\\(.*\\)['\"]$/\\1/p" $todoman_configuration_file 2>/dev/null))" + # default value according to documentation: https://todoman.readthedocs.io/en/stable/configure.html + if [[ -z "${date_format}" ]]; then + date_format="%x" + fi + if [[ -z "${dt_separator}" ]]; then +- dt_separator="" ++ dt_separator=" " + fi + if [[ -z "${time_format}" ]]; then +- time_format="%x" ++ time_format="%X" + fi + return 0 + else +@@ -150,7 +150,7 @@ __todo_lists(){ + zstyle ":completion:${curcontext}:" cache-policy __todo_lists_cache_policy + fi + local -a tasks_lists +- if _cache_invalid todoman_lists; then ++ if _cache_invalid todoman_lists || ! _retrieve_cache todoman_lists; then + if [[ ${tasks_lists_path} =~ '/*$' ]]; then + for dir in $(eval echo ${tasks_lists_path}); do + if grep "VTODO" -q -R "${dir}"; then +@@ -160,8 +160,6 @@ __todo_lists(){ + done + fi + _store_cache todoman_lists tasks_lists +- else +- _retrieve_cache todoman_lists + fi + if [[ "${#tasks_lists[@]}" == 1 ]]; then + _message "only one list was detected: (\"${tasks_lists[1]}\")" +@@ -243,7 +241,7 @@ _command_list_options=( + '(--reverse --no-reverse)'{--reverse,--no-reverse}'[sort tasks in reverse order (see --sort)]' + "${common_options_start[@]}" + "${common_options_due[@]}" +- '--priority[Only show tasks with priority at least as high as TEXT]:TEXT:("low", "medium", "high")' ++ '--priority=[Only show tasks with priority at least as high as TEXT]:TEXT:("low" "medium" "high")' + '--startable[Show only todos which should can be started today]' + {-s,--status=}'[Show only todos with the provided comma-separated statuses]:STATUS:{_values -s , "status" "NEEDS-ACTION" "CANCELLED" "COMPLETED" "IN-PROCESS" "ANY"}' + "${common_options_help[@]}" diff --git a/srcpkgs/todoman/template b/srcpkgs/todoman/template index 75584e7710c6..f954a2f83467 100644 --- a/srcpkgs/todoman/template +++ b/srcpkgs/todoman/template @@ -1,12 +1,12 @@ # Template file for 'todoman' pkgname=todoman version=4.1.0 -revision=1 +revision=2 build_style=python3-module hostmakedepends="python3-setuptools_scm" depends="python3-icalendar python3-urwid python3-xdg python3-parsedatetime python3-atomicwrites python3-click-repl python3-click-log - python3-dateutil python3-tabulate python3-humanize" + python3-dateutil python3-humanize jq" checkdepends="${depends} python3-freezegun python3-hypothesis python3-pytest-cov python3-pytest-xdist" short_desc="Simple, standards-based, cli todo (aka: task) manager" @@ -19,4 +19,7 @@ checksum=ce3caa481d923e91da9b492b46509810a754e2d3ef857f5d20bc5a8e362b50c8 post_install() { vlicense LICENCE + vcompletion contrib/completion/zsh/_todo zsh todo + vcompletion contrib/completion/bash/_todo bash todo + vsconf config.py.sample }