Skip to content

lib search returns exact match as the first result. #1975

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

Merged
merged 3 commits into from
Nov 15, 2022
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
Next Next commit
Removed global variable
  • Loading branch information
cmaglie committed Nov 14, 2022
commit 6e2c6099a27b80ccc89f1fe1c8085a6435d6938f
11 changes: 5 additions & 6 deletions cli/lib/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,23 @@ import (
semver "go.bug.st/relaxed-semver"
)

var (
namesOnly bool // if true outputs lib names only.
)

func initSearchCommand() *cobra.Command {
var namesOnly bool // if true outputs lib names only.
searchCommand := &cobra.Command{
Use: fmt.Sprintf("search [%s]", tr("LIBRARY_NAME")),
Short: tr("Searches for one or more libraries data."),
Long: tr("Search for one or more libraries data (case insensitive search)."),
Example: " " + os.Args[0] + " lib search audio",
Args: cobra.ArbitraryArgs,
Run: runSearchCommand,
Run: func(cmd *cobra.Command, args []string) {
runSearchCommand(args, namesOnly)
},
}
searchCommand.Flags().BoolVar(&namesOnly, "names", false, tr("Show library names only."))
return searchCommand
}

func runSearchCommand(cmd *cobra.Command, args []string) {
func runSearchCommand(args []string, namesOnly bool) {
inst, status := instance.Create()
logrus.Info("Executing `arduino-cli lib search`")

Expand Down