Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Conversation

aleixpol
Copy link
Collaborator

@aleixpol aleixpol commented Nov 7, 2022

Allows the command line interface to be used to list available components for certain categories.

Allows the command line interface to be used to list available
components for certain categories.
@aleixpol aleixpol requested a review from ximion November 7, 2022 16:47
@aleixpol
Copy link
Collaborator Author

aleixpol commented Nov 7, 2022

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",
Copy link
Owner

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.

Copy link
Collaborator Author

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. */
Copy link
Owner

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 (,)."),
Copy link
Owner

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);
Copy link
Owner

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.

Copy link
Collaborator Author

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);
Copy link
Owner

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?

@ximion ximion closed this in 47be2b2 Jan 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants