roman-neuhauser requested changes on this pull request.
looks better, thanks! we'll need feedback from authorities soon. :)
> @@ -65,6 +65,9 @@ usage(bool fail)
" -o --ownedby FILE Search for package files by matching STRING or REGEX\n"
" -S --show PKG Show information for PKG [default mode]\n"
" -s --search PKG Search for packages by matching PKG, STRING or REGEX\n"
+ " -P --printf FORMAT Print as FORMAT, for substitutions see man page\n"
+ " -u --unformatted Print search output without an formatting or description\n"
+ " Useful for installing multiple packages using regexs\n"
the previous line is still mis-indented.
> @@ -52,6 +52,59 @@ struct search_data {
};
static void
+print_results_formatted(struct xbps_handle *xhp, struct search_data *sd, const char *format)
+{
+ const char *pkgver, *desc;
+ char tmp[256], instc;
+ const char *origformat;
+ bool process = false;
+ instc = '+';
+ origformat = format;
+ /* Iterate over results array and find out largest pkgver string */
+ for (unsigned int i = 0; i < xbps_array_count(sd->results); i+=2)
+ xbps_array_get_cstring_nocopy(sd->results, i, &pkgver);
shouldn't the above loop be removed completely? it seems to serve no purpose.
> + instc = '+';
+ while (true) {
+ if ((char)(*format) == '\0') break;
+ if (process) {
+ switch ((char)(*format)) {
+ case '%':
+ printf("%%");
+ break;
+ case 'd':
+ printf("%s", desc);
+ break;
+ case 'i':
+ printf("%c", instc);
+ break;
+ case 'n':
+ printf("\n");
the previous line uses spaces for indentation, it should use tabs like everything else.