Implement XBPS completions (#7239)

This commit is contained in:
Allen Sobot 2020-08-05 20:01:19 +02:00 committed by GitHub
parent 8d3b66fb52
commit 54823c9243
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 334 additions and 0 deletions

View File

@ -136,6 +136,7 @@ Completions
- ``tig``
- ``windscribe``
- ``wireshark``, ``tshark``, and ``dumpcap``
- ``xbps-*``
- ``xxhsum``, ``xxh32sum``, ``xxh64sum`` and ``xxh128sum``
- ``yadm``
- ``zopfli``, and ``zopflipng``

View File

@ -0,0 +1,20 @@
# xbps-alternatives
# Author: Allen Sobot <chilledfrogs@disroot.org>
set -l progname xbps-alternatives
set -l listinstalled "(__fish_print_packages -i)"
complete -c $progname -f
complete -c $progname -a "$listinstalled"
complete -c $progname -s C -d 'Specifies a path to the XBPS configuration directory.' -xa "(__fish_complete_directories)"
complete -c $progname -s d -d 'Enables extra debugging shown to stderr.'
complete -c $progname -s g -d 'Alternative group name to match. To be used with the set mode.'
complete -c $progname -s h -d 'Show the help message.'
complete -c $progname -s r -d 'Specifies a full path for the target root directory.' -xa "(__fish_complete_directories)"
complete -c $progname -s v -d 'Enables verbose messages.'
complete -c $progname -s V -d 'Show the version information.'
complete -c $progname -s l -n "not __fish_contains_opt -s s" -d 'Lists all current alternative groups or only from PKG, or just a specific group with -g.'
complete -c $progname -s s -n "not __fish_contains_opt -s l" -d 'Set alternative groups specified by PKG or just a specific group with -g.'

View File

@ -0,0 +1,18 @@
# Completions for xbps-checkvers
# Author: Allen Sobot <chilledfrogs@disroot.org>
set -l progname xbps-checkvers
complete -c $progname -s C -d 'Specifies a path to the XBPS configuration directory.' -xa "(__fish_complete_directories)"
complete -c $progname -s D -d 'Specifies a full path to the void-packages repository.' -xa "(__fish_complete_directories)"
complete -c $progname -s d -d 'Enables extra debugging shown to stderr.'
complete -c $progname -s f -d 'Format according to the string format, inspired by printf.' -x
complete -c $progname -s h -d 'Show the help message.'
complete -c $progname -s i -d 'Ignore repositories defined in configuration files.'
complete -c $progname -s I -d 'Check for outdated installed packages rather than in repositories.'
complete -c $progname -s m -d 'Only process listed files.'
complete -c $progname -s R -d 'Repository to be added to the top of the list.'
complete -c $progname -s r -d 'Specifies a full path for the target root directory.' -xa "(__fish_complete_directories)"
complete -c $progname -s s -d 'List all packages found in the void-packages tree and prints available version.'
complete -c $progname -s V -d 'Show the version information.'

View File

@ -0,0 +1,36 @@
# Completions for xbps-create
# Author: Allen Sobot <chilledfrogs@disroot.org>
set -l progname xbps-create
set -l modes none gzip bzip2 xz lz4 zstd
complete -c $progname -f -a "(__fish_complete_directories)"
complete -c $progname -s A -d 'The target architecture for this package (required).' -x
complete -c $progname -s B -d 'The package builder string, free form.' -x
complete -c $progname -s C -d 'A list of package patterns that this package should conflict with, separated by whitespaces.' -x
complete -c $progname -s D -d 'A list of package patterns this package depends on, separated by whitespaces.' -x
complete -c $progname -s F -d 'A list of configuration files this package provides, separated by whitespace.' -x
complete -c $progname -s G -d 'This sets a string with the git revisions of the sourcepkg that was used to binary package.' -x
complete -c $progname -s H -d 'The package homepage string.' -x
complete -c $progname -s h -d 'Show the help message.'
complete -c $progname -s l -d 'The package license.' -x
complete -c $progname -s M -d 'A list of mutable files this package provides, separated by whitespaces.' -x
complete -c $progname -s m -d 'The package maintainer name and/or email contact.' -x
complete -c $progname -s n -d 'The package name/version tuple, e. g: \'foo-1. 0_1\'.' -x
complete -c $progname -s P -d 'A list of virtual packages this package provides, separated by whitespaces.' -x
complete -c $progname -s p -d 'If set the package files will be preserved after being updated.'
complete -c $progname -s q -d 'Enable quiet operation.'
complete -c $progname -s R -d 'A list of package patterns this package replaces, separated by whitespaces.' -x
complete -c $progname -s r -d 'A list of versions this package reverts, separated by whitespaces.' -x
complete -c $progname -s S -d 'A long description for this package.' -x
complete -c $progname -s s -d 'A short description for this package, one line with less than 80 characters.' -x
complete -c $progname -s t -d 'A list of tags (categories) this package should be part of, separated by whit…' -x
complete -c $progname -s V -d 'Show the version information.'
complete -c $progname -l build-options -d 'A string containing the build options used in package.' -x
complete -c $progname -l compression -d 'Set the binary package compression format. If unset, defaults to zstd.' -xa "$modes"
complete -c $progname -l shlib-provides -d 'A list of provided shared libraries, separated by whitespaces.' -x
complete -c $progname -l shlib-requires -d 'A list of required shared libraries, separated by whitespaces.' -x
complete -c $progname -l alternatives -d 'A list of alternatives provided by this package, separated by whitespaces.' -x
complete -c $progname -s c -d 'The package changelog string.' -x

View File

@ -0,0 +1,21 @@
# Completions for xbps-dgraph
# Author: Allen Sobot <chilledfrogs@disroot.org>
set -l progname xbps-dgraph
complete -c $progname -f
complete -c $progname -a "(__fish_print_packages -i)"
complete -c $progname -n "__fish_contains_opt -s R" -a "(__fish_print_packages)"
complete -c $progname -s C -d 'Specifies a path to the XBPS configuration directory.' -xa "(__fish_complete_directories)"
complete -c $progname -s c -d 'Specifies a path to the graph configuration file.' -F
complete -c $progname -s d -d 'Enables extra debugging shown to stderr.'
complete -c $progname -s h -d 'Show the help message.'
complete -c $progname -s M -d 'For remote repositories, the data is fetched and stored in memory.'
complete -c $progname -s R -d 'Enable repository mode.'
complete -c $progname -s r -d 'Specifies a full path for the target root directory.' -xa "(__fish_complete_directories)"
complete -c $progname -s V -d 'Show the version information.'
complete -c $progname -s g -n "not __fish_contains_opt -s f" -n "not __fish_contains_opt -s m" -d 'Generates a graph configuration file in the current working directory.'
complete -c $progname -s f -n "not __fish_contains_opt -s m" -n "not __fish_contains_opt -s g" -d 'Generates a full dependency graph of the target package.'
complete -c $progname -s m -n "not __fish_contains_opt -s f" -n "not __fish_contains_opt -s g" -d 'Generates a metadata graph of the target package.' # TODO: kinda fix this, can't exactly figure out how to make these last 3 modes mutually exclusive

View File

@ -0,0 +1,10 @@
# Completions for xbps-digest
# Author: Allen Sobot <chilledfrogs@disroot.org>
set -l progname xbps-digest
set -l modes sha256
complete -c $progname -s m -d 'Sets the message digest mode. If unset, defaults to sha256' -xa "$modes"
complete -c $progname -s h -d 'Show the help message.'
complete -c $progname -s V -d 'Show the version information.'

View File

@ -0,0 +1,14 @@
# Completions for xbps-fbulk
# Author: Allen Sobot <chilledfrogs@disroot.org>
set -l progname xbps-fbulk
complete -c $progname -f -a "(__fish_complete_directories) (__fish_print_packages)"
complete -c $progname -s a -d 'Set a different target architecture, useful for cross compiling.' -x
complete -c $progname -s j -d 'Set number of parallel builds running at the same time. By default set to 1.' -x
complete -c $progname -s l -d 'Set the log directory. By default set to `log. <pid>`.' -x
complete -c $progname -s d -d 'Enables extra debugging shown to stderr.'
complete -c $progname -s h -d 'Show the help message.'
complete -c $progname -s v -d 'Enables verbose messages.'
complete -c $progname -s V -d 'Show the version information.'

View File

@ -0,0 +1,13 @@
# Completions for xbps-fetch
# Author: Allen Sobot <chilledfrogs@disroot.org>
set -l progname xbps-fetch
complete -c $progname -f
complete -c $progname -s d -d 'Enables debug messages on stderr.'
complete -c $progname -s h -d 'Show the help message.'
complete -c $progname -s o -d 'Rename file from specified URL to output.' -F
complete -c $progname -s v -d 'Enables verbose messages.'
complete -c $progname -s V -d 'Show the version information.'

View File

@ -0,0 +1,31 @@
# Completions for xbps-install
# Author: Allen Sobot <chilledfrogs@disroot.org>
set -l progname xbps-install
set -l listall "(__fish_print_packages)"
complete -c $progname -f
complete -c $progname -a "$listall"
complete -c $progname -s A -d 'Enables automatic installation mode, i. e. treat as orphan unless dependency of already installed package.'
complete -c $progname -s C -d 'Specifies a path to the XBPS configuration directory.' -xa "(__fish_complete_directories)"
complete -c $progname -s c -d 'Specifies a path to the cache directory, where binary packages are stored.' -xa "(__fish_complete_directories)"
complete -c $progname -s d -d 'Enables extra debugging shown to stderr.'
complete -c $progname -s D -d 'Only download packages to the cache, do not do any other installation steps.'
complete -c $progname -s f -d 'Force downgrade/reinstall package (pass option twice to reinstall config files as well).'
complete -c $progname -s h -d 'Show the help message.'
complete -c $progname -s I -d 'Ignore detected file conflicts in a transaction.'
complete -c $progname -s i -d 'Ignore repositories defined in configuration files.'
complete -c $progname -s M -d 'For remote repositories, the data is fetched and stored in memory.'
complete -c $progname -s n -d 'Dry-run mode. Show what actions would be done but don\'t do anything.'
complete -c $progname -s R -d 'Enable repository mode.'
complete -c $progname -l repository -d 'Appends the specified repository to the top of the list.'
complete -c $progname -s r -d 'Specifies a full path for the target root directory.' -xa "(__fish_complete_directories)"
complete -c $progname -s S -d 'Synchronize remote repository index files.'
complete -c $progname -s U -d 'If set, packages to be installed or upgraded in the transaction won\'t be configured.'
complete -c $progname -s u -d 'Performs a full system upgrade (except for packages on hold).'
complete -c $progname -s v -d 'Enables verbose messages.'
complete -c $progname -s y -d 'Assume yes to all questions and avoid interactive questions.'
complete -c $progname -s V -d 'Show the version information.'

View File

@ -0,0 +1,19 @@
# Completions for xbps-pkgdb
# Author: Allen Sobot <chilledfrogs@disroot.org>
set -l progname xbps-pkgdb
set -l modes auto manual hold unhold repolock repounlock
complete -c $progname -f
complete -c $progname -s a -d 'Process all registered packages, regardless of its state.'
complete -c $progname -s C -d 'Specifies a path to the XBPS configuration directory.' -xa "(__fish_complete_directories)"
complete -c $progname -s d -d 'Enables extra debugging shown to stderr.'
complete -c $progname -s h -d 'Show the help message.'
complete -c $progname -s m -d 'Set mode of PKGNAME' -xa "$modes"
complete -c $progname -n "__fish_seen_subcommand_from $modes" -xa "(__fish_print_packages -i)"
complete -c $progname -s r -d 'Specifies a full path for the target root directory.' -xa "(__fish_complete_directories)"
complete -c $progname -s u -d 'Updates the pkgdb format to the latest version making the necessary conversions.'
complete -c $progname -s v -d 'Enables verbose messages.'
complete -c $progname -s V -d 'Show the version information.'

View File

@ -0,0 +1,39 @@
# Completions for xbps-query
# Author: Allen Sobot <chilledfrogs@disroot.org>
set -l progname xbps-query
set -l listall "(__fish_print_packages)"
set -l listinstalled "(__fish_print_packages -i)"
complete -c $progname -f
complete -c $progname -a "$listinstalled"
complete -c $progname -n "__fish_contains_opt -s R" -a "$listall"
complete -c $progname -s C -d 'Specifies a path to the XBPS configuration directory.' -xa "(__fish_complete_directories)"
complete -c $progname -s c -d 'Specifies a path to the cache directory, where binary packages are stored.' -xa "(__fish_complete_directories)"
complete -c $progname -s d -d 'Enables extra debugging shown to stderr.'
complete -c $progname -s h -d 'Show the help message.'
complete -c $progname -s i -d 'Ignore repositories defined in configuration files.'
complete -c $progname -s M -d 'For remote repositories, the data is fetched and stored in memory only.'
complete -c $progname -s p -d 'Only match this package property.'
complete -c $progname -s R -d 'Enable repository mode.'
complete -c $progname -l repository -d 'Appends the specified repository to the top of the list.'
complete -c $progname -l regex -d 'Enables string matching by using Extended Regular Expressions in compatible modes'
complete -c $progname -l fulldeptree -d 'Prints a full dependency tree in the show dependencies mode.'
complete -c $progname -s r -d 'Specifies a full path for the target root directory.' -xa "(__fish_complete_directories)"
complete -c $progname -s v -d 'Enables verbose messages.'
complete -c $progname -s V -d 'Show the version information.'
complete -c $progname -s l -d 'Lists registered packages in the package database (pkgdb).'
complete -c $progname -s H -d 'List registered packages in the package database (pkgdb) that are on hold.'
complete -c $progname -s L -d 'Lists repositories and the number of packages contained on them.'
complete -c $progname -s m -d 'Lists registered packages in the package database (pkgdb) that were installed manually'
complete -c $progname -s O -d 'Lists package orphans in the package database (pkgdb)'
complete -c $progname -s o -d 'Search for installed package files by matching PATTERN.'
complete -c $progname -s S -d 'Shows information of an installed package.' -x
complete -c $progname -s s -d 'Search for packages by matching PATTERN on its pkgver and/or short_desc properties'
complete -c $progname -s f -d 'Show the package files for PKG.' -x
complete -c $progname -s x -d 'Show the required dependencies for PKG. Only direct dependencies are shown.' -x
complete -c $progname -s X -d 'Show the reverse dependencies for PKG.' -x
complete -c $progname -l cat -d 'Prints the file FILE stored in binary package PKG to stdout.' -F

View File

@ -0,0 +1,20 @@
# Completions for xbps-reconfigure
# Author: Allen Sobot <chilledfrogs@disroot.org>
set -l progname xbps-reconfigure
set -l listinstalled "(__fish_print_packages -i)"
complete -c $progname -f
complete -c $progname -a "$listinstalled"
complete -c $progname -s a -d 'Configures all packages.'
complete -c $progname -s C -d 'Specifies a path to the XBPS configuration directory.' -xa "(__fish_complete_directories)"
complete -c $progname -s d -d 'Enables extra debugging shown to stderr.'
complete -c $progname -s f -d 'Forcefully reconfigure package even if it was configured previously.'
complete -c $progname -s h -d 'Show the help message.'
complete -c $progname -s i -n "__fish_contains_opt -s a" -d 'Ignore PKG when configuring all packages, can be specified multiple times.' -xa "$listinstalled"
complete -c $progname -s r -d 'Specifies a path for the target root directory.' -xa "(__fish_complete_directories)"
complete -c $progname -s v -d 'Enables verbose messages.'
complete -c $progname -s V -d 'Show the version information.'

View File

@ -0,0 +1,25 @@
# Completions for xbps-remove
# Author: Allen Sobot <chilledfrogs@disroot.org>
set -l progname xbps-remove
set -l listinstalled "(__fish_print_packages -i)"
complete -c $progname -f
complete -c $progname -a "$listinstalled"
complete -c $progname -s C -d 'Specifies a path to the XBPS configuration directory.' -xa "(__fish_complete_directories)"
complete -c $progname -s c -d 'Specifies a path to the cache directory, where binary packages are stored.' -xa "(__fish_complete_directories)"
complete -c $progname -s d -d 'Enables extra debugging shown to stderr.'
complete -c $progname -s F -d 'Forcefully remove package even if there are reverse dependencies and/or broke…'
complete -c $progname -s f -d 'Forcefully remove package files even if they have been modified.'
complete -c $progname -s h -d 'Show the help message.'
complete -c $progname -s n -d 'Dry-run mode. Show what actions would be done but don\'t do anything.'
complete -c $progname -s O -d 'Cleans cache directory removing obsolete binary packages.'
complete -c $progname -s o -d 'Removes installed package orphans that were installed automatically (as dependencies)'
complete -c $progname -s R -d 'Recursively remove packages that were installed by PKGNAME and aren\'t required by any other package'
complete -c $progname -s r -d 'Specifies a full path for the target root directory.' -xa "(__fish_complete_directories)"
complete -c $progname -s v -d 'Enables verbose messages.'
complete -c $progname -s y -d 'Assume yes to all questions and avoid interactive questions.'
complete -c $progname -s V -d 'Show the version information.'

View File

@ -0,0 +1,22 @@
# Completions for xbps-rindex
# Author: Allen Sobot <chilledfrogs@disroot.org>
set -l progname xbps-rindex
set -l modes none gzip bzip2 xz lz4 zstd
complete -c $progname -f
complete -c $progname -s d -d 'Enables extra debugging shown to stderr.'
complete -c $progname -l compression -d 'Set the repodata compression format. If unset, defaults to zstd.' -xa "$modes"
complete -c $progname -s C -d 'Check not only for file existence but for the correct file hash while cleaning.'
complete -c $progname -s f -d 'Forcefully register binary package into the local repository, overwriting existing entry.'
complete -c $progname -s h -d 'Show the help message.'
complete -c $progname -s V -d 'Show the version information.'
complete -c $progname -l signedby -d 'Name and email of person signing the repository.'
complete -c $progname -l privkey -d 'Path to the private RSA key to sign the repository. Defaults to ~/.ssh/id_rsa' -F
complete -c $progname -s a -d 'Registers the binary package into the local repository.' -xa "(__fish_complete_suffix .xbps)"
complete -c $progname -s c -d 'Removes obsolete entries found in the local repository.' -xa "(__fish_complete_directories)"
complete -c $progname -s r -d 'Removes obsolete and currently unregistered packages from the local repository.' -xa "(__fish_complete_directories)"
complete -c $progname -s s -d 'Initializes a signed repository with your specified RSA key.' -xa "(__fish_complete_directories)"
complete -c $progname -s S -d 'Signs a binary package archive with your specified RSA key.' -xa "(__fish_complete_suffix .xbps)"

View File

@ -0,0 +1,12 @@
# Completions for xbps-uchroot
# Author: Allen Sobot <chilledfrogs@disroot.org>
set -l progname xbps-uchroot
complete -c $progname -f -a "(__fish_complete_directories)"
complete -c $progname -s b -d 'Bind mounts src into CHROOTDIR/dest.' -F
complete -c $progname -s O -d 'Setups a temporary directory and then creates an overlay layer (via overlayfs).'
complete -c $progname -s o -d 'Arguments passed to the tmpfs mount, if the O and t options are specified.'
complete -c $progname -s t -d 'This makes the temporary directory to be mounted in tmpfs, so that everything is stored in RAM. Used only with -O.'

View File

@ -0,0 +1,12 @@
# Completions for xbps-uhelper
# Author: Allen Sobot <chilledfrogs@disroot.org>
set -l progname xbps-uhelper
set -l actions binpkgarch binpkgver cmpver getpkgdepname getpkgdepversion getpkgname getpkgrevision getpkgversion pkgmatch version real-version
complete -c $progname -f -a "$actions (__fish_print_packages -i)"
complete -c $progname -s C -d 'Path to xbps.conf file.' -rF
complete -c $progname -s d -d 'Debugging messages to stderr.'
complete -c $progname -s r -d 'Path to rootdir.' -xa "(__fish_complete_directories)"
complete -c $progname -s V -d 'Prints the XBPS release version.'

View File

@ -242,4 +242,25 @@ function __fish_print_packages
end
end
# Caches for 5 minutes
if type -q -f xbps-query
if not set -q only_installed
set -l cache_file $xdg_cache_home/.xbps-cache.$USER
if test -f $cache_file
cat $cache_file
set -l age (math (date +%s) - (stat -c '%Y' $cache_file))
set -l max_age 300
if test $age -lt $max_age
return
end
end
# prints: <package name> Package
xbps-query -Rsl | sed 's/^... \([^ ]*\)-.* .*/\1/; s/$/\t'Package'/' > $cache_file &
return
else
xbps-query -l | sed 's/^.. \([^ ]*\)-.* .*/\1/' # TODO: actually put package versions in tab for locally installed packages
return
end
end
end