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

feat: make cli closer to npm #413

Merged
merged 6 commits into from
Nov 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
search cmd
  • Loading branch information
ComradeVanti committed Nov 1, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 3bc409574994dbbef932f5e6915cfc26da1d5116
28 changes: 17 additions & 11 deletions src/cli/cmd-search.ts
Original file line number Diff line number Diff line change
@@ -47,13 +47,15 @@ export function makeSearchCmd(
);

return new Command("search")
.argument("<keyword>", "The keyword to search")
.argument("<search term>", "The term to search for")
.addOption(primaryRegistryUrlOpt)
.addOption(systemUserOpt)
.aliases(["s", "se", "find"])
.description("Search package by keyword")
.summary("search packages matching a term")
.description(`Search all packages matching a given search term.
openupm search math`)
.action(
withErrorLogger(log, async function (keyword, options) {
withErrorLogger(log, async function (searchTerm, options) {
const homePath = getHomePathFromEnv(process.env);
const upmConfigPath = getUserUpmConfigPathFor(
process.env,
@@ -67,16 +69,20 @@ export function makeSearchCmd(
);

let usedEndpoint = "npmsearch";
const results = await searchPackages(primaryRegistry, keyword, () => {
usedEndpoint = "endpoint.all";
log.warn(
"",
"fast search endpoint is not available, using old search."
);
});
const results = await searchPackages(
primaryRegistry,
searchTerm,
() => {
usedEndpoint = "endpoint.all";
log.warn(
"",
"fast search endpoint is not available, using old search."
);
}
);

if (results.length === 0) {
log.notice("", `No matches found for "${keyword}"`);
log.notice("", `No matches found for "${searchTerm}"`);
return process.exit(ResultCodes.Ok);
}