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

Bug 1904132 - Suggest CLI #6280

Merged
merged 1 commit into from
Jun 25, 2024
Merged

Bug 1904132 - Suggest CLI #6280

merged 1 commit into from
Jun 25, 2024

Conversation

bendk
Copy link
Contributor

@bendk bendk commented Jun 24, 2024

Added the suggest-cli crate that implements a simple clap CLI to ingest and query suggestions. This can be run using cargo suggest.

My plan is to use this to test fakespot blocklist support.

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

Branch builds: add [firefox-android: branch-name] to the PR title.

@bendk bendk requested a review from a team June 24, 2024 15:07
@codecov-commenter
Copy link

codecov-commenter commented Jun 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@a8c15ba). Learn more about missing BASE report.
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6280   +/-   ##
=======================================
  Coverage        ?   22.64%           
=======================================
  Files           ?      330           
  Lines           ?    29814           
  Branches        ?        0           
=======================================
  Hits            ?     6750           
  Misses          ?    23064           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@gruberb gruberb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one little suggestion. Also, since it's just local, it's probably fine to have .unwrap()s. I personally would log them via eprintln! at least, so in case something goes wrong, it's easier to see where the problem is.

}

fn query(store: &SuggestStore, provider: SuggestionProviderArg, input: String) {
let provider = match provider {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's "just" for local testing, but would be a bit cleaner to have a impl From>SuggestionProviderArg> so we can do let provider = SuggestionProvider::from(provider_args);

impl From<SuggestionProviderArg> for SuggestionProvider {
    fn from(arg: SuggestionProviderArg) -> Self {
        match arg {
            SuggestionProviderArg::Amp => SuggestionProvider::Amp,
            SuggestionProviderArg::Wikipedia => SuggestionProvider::Wikipedia,
            SuggestionProviderArg::Amo => SuggestionProvider::Amo,
            SuggestionProviderArg::Pocket => SuggestionProvider::Pocket,
            SuggestionProviderArg::Yelp => SuggestionProvider::Yelp,
            SuggestionProviderArg::Mdn => SuggestionProvider::Mdn,
            SuggestionProviderArg::Weather => SuggestionProvider::Weather,
            SuggestionProviderArg::AmpMobile => SuggestionProvider::AmpMobile,
            SuggestionProviderArg::Fakespot => SuggestionProvider::Fakespot,
        }
    }
}

Added the `suggest-cli` crate that implements a simple clap CLI to
ingest and query suggestions.  This can be run using `cargo suggest`.

My plan is to use this to test fakespot blocklist support.
@bendk
Copy link
Contributor Author

bendk commented Jun 25, 2024

Thanks for the suggestions, the code is looking much better now. I ended up replacing the unwraps with unwrap_or_else plus a panic. That should lead to an okay error message being printed out.

@bendk bendk enabled auto-merge June 25, 2024 21:07
@bendk bendk added this pull request to the merge queue Jun 25, 2024
Merged via the queue into mozilla:main with commit ee75ab4 Jun 25, 2024
16 of 17 checks passed
@bendk bendk deleted the bug-1904132 branch June 25, 2024 22:06
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.

3 participants