From: Colin Clark Date: Mon, 1 Apr 2024 18:56:50 +0000 (+0100) Subject: Implement basic command line auto-completion X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=945ce15b6d3ebd988948bf8911f450cc77fb1bc9 Implement basic command line auto-completion _parse_help is used to provide auto-completion for long options. No other processing is done. --- diff --git a/auto-complete/geeqie b/auto-complete/geeqie new file mode 100755 index 00000000..4dd9b832 --- /dev/null +++ b/auto-complete/geeqie @@ -0,0 +1,20 @@ +#!/bin/bash + +_geeqie() +{ + local cur + _init_completion -s || return + + if [[ $cur == -* ]] + then + # shellcheck disable=SC2207 + # shellcheck disable=SC2016 + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace + return + fi + +} && + complete -F _geeqie geeqie + +# ex: filetype=sh diff --git a/auto-complete/meson.build b/auto-complete/meson.build new file mode 100644 index 00000000..19438d6f --- /dev/null +++ b/auto-complete/meson.build @@ -0,0 +1,14 @@ +# This file is a part of Geeqie project (https://www.geeqie.org/). +# Copyright (C) 2008 - 2024 The Geeqie Team +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# + +install_data('geeqie', install_dir : completionsdir) diff --git a/meson.build b/meson.build index 946e285b..90ac63cc 100644 --- a/meson.build +++ b/meson.build @@ -34,6 +34,7 @@ # [gq_]htmldir /usr/local/share/doc/geeqie/html * help files # gq_localedir /usr/locale/share/locale # mandir1 /usr/local/share/man/man1 man page +# completionsdir /usr/local/share/bash-completion/completions bash command line completions # podir project_root/po # * See meson_options.txt file @@ -134,7 +135,7 @@ helpdir = join_paths(prefix, gq_helpdir) htmldir = join_paths(prefix, gq_htmldir) icondir = join_paths(datadir, 'pixmaps') mandir1 = join_paths(datadir, 'man', 'man1') - +completionsdir = join_paths(datadir, 'bash-completion', 'completions') podir = join_paths(meson.project_source_root(), 'po') scriptsdir = join_paths(meson.project_source_root(), 'scripts') @@ -616,6 +617,9 @@ subdir('src') # Generate the help files subdir('doc') +# Generate the command line auto-complete file +subdir('auto-complete') + # Install other project files if running_from_git cmd = [find_program('gen_changelog.sh'), meson.current_source_dir(), meson.current_build_dir()]