New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ascli: Allow searching by categories #447
Conversation
Allows the command line interface to be used to list available components for certain categories.
|
I set it up for debugging purposes, I figured it might be useful to others, as it's part of the public API anyway. |
| @@ -1252,6 +1282,12 @@ as_client_run (char **argv, int argc) | |||
| /* TRANSLATORS: `appstreamcli what-provides` command description. */ | |||
| _("Get components which provide the given item. Needs an item type (e.g. lib, bin, python3, …) and item value as parameter."), | |||
| as_client_run_what_provides); | |||
| ascli_add_cmd (commands, | |||
| 0, "by-categories", NULL, "NAMES", | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the naming here... It would make sense to implement this as a search filter, to search by category in appstreamcli search, but if this stays the way it is something like category-contents might make more sense: appstreamcli category-contents AudioVideo or appstreamcli search --by-category=AudioVideo mysearchterm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I don't mind either way. In fairness, I'd forgotten about this PR already.
| @@ -1252,6 +1282,12 @@ as_client_run (char **argv, int argc) | |||
| /* TRANSLATORS: `appstreamcli what-provides` command description. */ | |||
| _("Get components which provide the given item. Needs an item type (e.g. lib, bin, python3, …) and item value as parameter."), | |||
| as_client_run_what_provides); | |||
| ascli_add_cmd (commands, | |||
| 0, "by-categories", NULL, "NAMES", | |||
| /* TRANSLATORS: `appstreamcli what-provides` command description. */ | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Translator hint needs update.
| ascli_add_cmd (commands, | ||
| 0, "by-categories", NULL, "NAMES", | ||
| /* TRANSLATORS: `appstreamcli what-provides` command description. */ | ||
| _("Get components that are part of the specified categories in a list with comas (,)."), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Maybe better: List components that are part of the specified categories (listed separated by commas).
| return 1; | ||
| } | ||
|
|
||
| g_auto(GStrv) cats = g_strsplit(categories, ",", 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No declarations after statements please, we (still) need to be compatible with older C versions/compilers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I've ever seen a compiler that required it and I've been doing C for about 20 years now.
| result = as_pool_get_components_by_categories (dpool, cats); | ||
| if (result->len == 0) { | ||
| /* TRANSLATORS: We failed to find any component in the database, likely due to an error */ | ||
| ascli_print_stderr (_("Unable to find components matching %s!"), categories); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Maybe just call it Unable to find components in categories "%s"! to make this more clear?
Allows the command line interface to be used to list available components for certain categories.