bin/xbps-query: allow search in manual only mode
Small change, that allows to use search mode only in manually installed packages.
I find it extremely useful for tools like xilog, xhog and other similar search tools/queries, as most times I want information only about manual pkgs.
I am not sure if this patch will be wanted, but I don't lose anything by submitting it, so feel free to close the PR if it is not wanted.
Needs documentation. I would prefer to -R -m conflict like xbps-rindex modes do unless there is scenario when -R -m is really useful.
About -R and -m, there is no scenario in which they should be used together. As -m will just drop all remote pkgs that are not installed and marked manual, thus making the -R obsolete — conflict it is.
Will refactor based on the suggested enum and will update the docs.
I have pushed an update for the documentation, I decide to leave the usage message mostly as it is, and here is a compiled version of the changes to the man page.
-p, --property PROP[,...]
In --show mode, print only the selected property; multiple properties
can be specified by delimiting them with commas. In --search mode,
match packages based on the given property; only single property
matching is supported.
-R, --repository
Enable repository mode. This mode explicitly looks in repositories,
rather than looking in the target root directory.
MODE
Only one of the following modes can be used at a time, with the slight
exception of --list-manual-pkgs (-m) and --search (-s) they can be
enabled together.
By default and unless --repository (-R) mode is supported and enabled,
the target PKG will be queried in the root directory, otherwise it will
be queried in registered repositories.
-o, --ownedby PATTERN [--regex] [--repository]
Search for installed package files by matching PATTERN. The PATTERN
can be a simple string, a shell wildcard pattern as explained in
fnmatch(3) or an Extended Regular Expression as explained in regex(7)
(if the --regex option is set). Supports --repostiory mode, but it
is very slow; xlocate(1) from xtools(1) is prefered for such
searches.
-S, --show PKG [--property PROP] [--repository]
Shows information of an installed package. This is the default mode
if no other mode is set. If a package property is specified with
--property, only that property will be shown (multiple properties
supported with commas). Supports --repostiory mode, and if enabled
the matched PKG in repositories will be shown.
-s, --search PATTERN
[--regex] [--property PROP] [--list-manual-pkgs | --repository]
Search for packages by matching PATTERN on its pkgver and/or
short_desc properties. The same rules explained in the --ownedby
option are applied, but a PACKAGE EXPRESSION is also supported. If a
package property is specified with --property, all packages matching
PATTERN against PROP will be shown. If the --list-manual-pkgs option
is set, only explicitly installed packages will be shown. If
--repostiory mode is enabled the matched PKG in repositories will be
shown.
-f, --files PKG [--repository]
Show the package files for PKG. Supports --repostiory mode.
-x, --deps PKG [--fulldeptree] [--repository]
Show the required dependencies for PKG. Only direct dependencies are
shown. To see a full dependency tree, also set --fulldeptree.
Supports --repostiory mode.
-X, --revdeps PKG [--repository]
Show the reverse dependencies for PKG. Supports --repostiory mode.
Of course some of the highlighting is lost in github, but I didn't want to attach screenshots as it is about the content not the looks, for best results check the source :)
I have tried to separate the changes, as best as I can; I may have gone a bit overboard on the guards and checks for the conflicting options.
@Chocimier should be good now, for further review.
Also, for the record I have done my best to test all changes, but mostly just hashed search results with the changes and without the changes, to ensure all is good.
I have pushed a fast update, that fixes the typos and other similar things; for the other comments, I will push and update later this week, as I currently have only a phone.
Sorry for my absence, but now that I am back, is there still interest in this PR? Should I complete the changes?
Edit: either way, I pushed the requested changes, as they make the patch better and I am using this version on my machines
@Chocimier feel free to check it again, I welcome any suggestions
Sorry for my absence, but now that I am back, is there still interest in this PR? Should I complete the changes?
When implementing https://github.com/rami3l/pacaptr/pull/330, I found the lack of this feature really inconvenient, seems like a great addition!
force-pushed an update, that fixes the conflict with the latest manpage update