diff --git a/INSTALL.txt b/INSTALL.txt index cfb63ad..0bb6213 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -1,4 +1,4 @@ -A Makefile is provided for installation of the hoorex application +A Makefile is provided for installation of the HooRex application and manpage. Run (as root): make install @@ -6,3 +6,10 @@ and manpage. Run (as root): REQUIREMENTS. - the a2x utility (a Python script) is used to generate the man page so the python and linuxdoc-tools packages will need to be installed. +- for commandline tab completion under bash, the bash-completion package +(found in the Slackware CD's "extra" directory) must be installed. Only +terminals instantiated after installing both bash-completion and HooRex +will have tab completion enabled. Existing terminals may be enabled by +running the command: + . /usr/share/bash-completion/bash_completion + diff --git a/Makefile b/Makefile index 80ba01e..79c43cf 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,9 @@ all: hoorex man man: hoorex.1 -hoorex: VERSION.txt - sed -i -e "s/^HOOREX_VERSION.*/HOOREX_VERSION = \'$$(cat VERSION.txt)\'/" hoorex +hoorex: VERSION.txt hoorex.in + sed -e "s/^HOOREX_VERSION.*/HOOREX_VERSION = \'$$(cat VERSION.txt)\'/" hoorex.in > hoorex + chmod a+x hoorex hoorex.1: hoorex.1.in a2x -f manpage $? @@ -15,15 +16,16 @@ install: hoorex man install -m 0755 -D hoorex $(DESTDIR)/usr/bin/hoorex install -m 0644 -D hoorex.1 $(DESTDIR)/usr/man/man1/hoorex.1 install -m 0644 -D completions/zsh/_hoorex $(DESTDIR)/usr/share/zsh/site-functions/_hoorex + install -m 0644 -D completions/bash/hoorex $(DESTDIR)/usr/share/bash-completion/completions/hoorex uninstall: - rm $(DESTDIR)/usr/bin/hoorex - rm $(DESTDIR)/usr/man/man1/hoorex.1 - rm $(DESTDIR)/usr/share/zsh/site-functions/_hoorex + rm -f $(DESTDIR)/usr/bin/hoorex + rm -f $(DESTDIR)/usr/man/man1/hoorex.1* + rm -f $(DESTDIR)/usr/share/zsh/site-functions/_hoorex + rm -f $(DESTDIR)/usr/share/bash-completion/completions/hoorex clean: - rm -f hoorex.1 - sed -i -e "s/^HOOREX_VERSION.*/HOOREX_VERSION = 'X.Y.Z'/" hoorex + rm -f hoorex.1 hoorex .PHONY: clean .PHONY: hoorex diff --git a/README.md b/README.md index 7c47c74..f479bd2 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,7 @@ HooRex addresses these issues (and more) by generating and cacheing the dependency relationships between all packages in the repository, enabling a rapid response to dependency queries. +Command line Tab completion is now available for bash and zsh. Completions for +HooRex should just work for any new zsh instances invoked after HooRex has been +installed. For completions using bash, ensure that the bash-completions package +(available from the Slackware repo's "extra" section) has been installed. diff --git a/VERSION.txt b/VERSION.txt index ee6cdce..b616048 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -0.6.1 +0.6.2 diff --git a/completions/bash/hoorex b/completions/bash/hoorex new file mode 100644 index 0000000..ab16caf --- /dev/null +++ b/completions/bash/hoorex @@ -0,0 +1,111 @@ +#!/bin/sh + + +# If "sbo_path" is already set in config file, all options are available +grep sbo_path ~/.config/hoorex/defaults.cfg >/dev/null +if [ "$?" = "0" ]; then + # Master array of options + _comp_descriptions=( + '-d --debug (Enable additional debugging output)' + '-f --force (Recalculate all internal cross reference index)' + '-g --group (Use a predefined group of packages as input)' + '-h --help (Show help)' + '-1 --column (Single column output of results)' + '-p --dataPath (Alternate directory to store reference index file)' + '-i --installed (Restrict output to packages already installed)' + '-I --installed_strict (Restrict output to packages already installed - not even the initial target)' + '-l --long (Include category of each result output)' + '-m --multilevel (Show dependencies beyond the first level)' + '-r --reverse (Reverse display direction of dependencies i.e. show packages required to build the target)' + '-R --restricted (Restrict results to those named in the input list)' + '-s --slackbuilds (Specify full path to SBo repo)' + '-U --unknown_strict (Announce unknown packages and exit)' + '-V --version (Show version number and exit)' + ); + + # find out which SBO repo hoorex is configured for + _comp_sborepo="$(grep 'sbo_path' ~/.config/hoorex/defaults.cfg | cut -d= -f2 | xargs)" + + # Find the top level directories of repo (SBo groups: games, network, etc. + "all") + _comp_sbogroups="$(find $_comp_sborepo -not -path '*/\.*' -type d -mindepth 1 -maxdepth 1 -printf '%f ') all" + + # Listing of all slackbuilds + _comp_sbobuilds=$(hoorex -g all -1 |sort) +else + # "sbo_path" not set in config file => only -s|--slackbuilds option should be offered + _comp_descriptions=( '-s --slackbuilds (Specify full path to SBo repo)' ); +fi + +# Create an array of short options based on the master above +_comp_dcount=0 +while [ "x${_comp_descriptions[_comp_dcount]}" != "x" ] +do + # Add 1st element of each entry in _comp_descriptions array + _comp_short_opts[$_comp_dcount]=$(echo ${_comp_descriptions[_comp_dcount]} | cut -d ' ' -f 1); + + _comp_dcount=$(( $_comp_dcount + 1 )); +done + +_hoorex () +{ + local cur prev + + cur=${COMP_WORDS[COMP_CWORD]} + + if [[ $COMP_CWORD -gt 1 ]] ; then + prev=${COMP_WORDS[COMP_CWORD-1]}; + case $prev in + -g*|--group*) + COMPREPLY=($(compgen -W '${_comp_sbogroups}' -- "$cur")); + return; + ;; + -h*|--help*) + return; + ;; + -p*|--dataPath*) + #echo -n " N.B. The -p|--dataPath option needs full path to alternate directory to store reference index file"; + return 1; + ;; + -s*|--slackbuilds*) + #echo -n " N.B. The -s|--slackbuilds option needs full path to SBo slackbuilds tree"; + return 1; + ;; + -d|-f|-h|-1|-i|-I|-l|-m|-r|-R|-U|-V|\ + --debug|--force|--help|--column|--installed|--installed_strict|\ + --long|--multilevel|--reverse|--restricted|--unknown_strict|--version) + COMPREPLY=($(compgen -W '${_comp_sbobuilds}' -- "$cur")); + ;; + -*) + COMPREPLY=($(compgen -W '${_comp_short_opts[*]}' -- "$cur")); + return; + ;; + esac + case $cur in + --*) + COMPREPLY=($(compgen -W '${_comp_descriptions[*]}' -- "$cur")); + ;; + -*) + COMPREPLY=($(compgen -W '${_comp_short_opts[*]}' -- "$cur")); + ;; + *) + COMPREPLY=($(compgen -W '${_comp_sbobuilds}' -- "$cur")); + ;; + esac + else + case $cur in + --*) + COMPREPLY=($(compgen -W '${_comp_descriptions[*]}' -- "$cur")); + ;; + -*) + COMPREPLY=($(compgen -W '${_comp_short_opts[*]}' -- "$cur")); + ;; + *) + COMPREPLY=($(compgen -W '${_comp_sbobuilds}' -- "$cur")); + ;; + esac + fi + +} +complete -F _hoorex hoorex + +# ex:set ai shiftwidth=2 inputtab=spaces smarttab noautotab: diff --git a/completions/zsh/_hoorex b/completions/zsh/_hoorex index 379f073..2d4d45e 100644 --- a/completions/zsh/_hoorex +++ b/completions/zsh/_hoorex @@ -7,7 +7,7 @@ if [ -f ~/.config/hoorex/defaults.cfg ]; then # find out which SBO repo hoorex is configured for sborepo="$(grep 'sbo_path' ~/.config/hoorex/defaults.cfg | cut -d= -f2 | xargs)" # get the top level directories of repo (SBo groups, games, network, etc.) - sbogroups=( ${(uf)"$(find $sborepo -type d -mindepth 1 -maxdepth 1 -printf '%f\n')"} ) + sbogroups=( ${(uf)"$(find $sborepo -not -path '*/\.*' -type d -mindepth 1 -maxdepth 1 -printf '%f\n')"} ) # hoorex also recognises the group "all" sbogroups="${sbogroups} all" # grab a listing of all slackbuilds (just use the directory names) diff --git a/hoorex b/hoorex.in similarity index 96% rename from hoorex rename to hoorex.in index 0829d69..2429b00 100755 --- a/hoorex +++ b/hoorex.in @@ -2,6 +2,24 @@ # # ex:set ai shiftwidth=4 inputtab=spaces smarttab noautotab: +""" +Copyright (c) 2017-18 Christoph Willing, Brisbane Australia + +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 3 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 +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program (see LICENSE.md). If not, +see . +""" + from __future__ import print_function import sys, os