Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var KeyMap = keymap{ Enter: key.NewBinding( key.WithKeys("enter"), key.WithHelp("enter", "select"), ), Back: key.NewBinding( key.WithKeys("esc"), key.WithHelp("esc", "back"), ), Quit: key.NewBinding( key.WithKeys("ctrl+c"), key.WithHelp("ctrl+c", "quit"), ), Space: key.NewBinding( key.WithKeys(" "), key.WithHelp("space", "toggle"), ), Up: key.NewBinding( key.WithKeys("up", "k"), key.WithHelp("↑/k", "up"), ), Down: key.NewBinding( key.WithKeys("down", "j"), key.WithHelp("↓/j", "down"), ), }
KeyMap reusable key mappings shared across models
View Source
var SearchCmd = &cobra.Command{ Use: "search", Short: "search searches for packages", Long: `Search for Nix packages on the Nixpkgs repository `, Example: `bsf search <package name>`, Run: func(cmd *cobra.Command, args []string) { if len(args) < 1 { fmt.Println(errorStyle.Render(fmt.Errorf("error: %v", "package name is required").Error())) os.Exit(1) } var err error conf, err := configure.PreCheckConf() if err != nil { fmt.Println(styles.ErrorStyle.Render("error:", err.Error())) os.Exit(1) } if os.Getenv("BSF_DEBUG") != "" && strings.ToLower(os.Getenv("BSF_DEBUG")) == "true" { if f, err := tea.LogToFile("debug.log", "help"); err != nil { fmt.Println("Couldn't open a file for logging:", err) os.Exit(1) } else { defer func() { err = f.Close() if err != nil { log.Fatal(err) } }() } } sc, err = search.NewClientWithAddr(conf.BuildSafeAPI, conf.BuildSafeAPITLS) if err != nil { fmt.Println(errorStyle.Render(fmt.Errorf("error: %v", err).Error())) os.Exit(1) } packages, err := sc.ListPackages(cmd.Context(), &buildsafev1.ListPackagesRequest{ PageSize: 999, PageToken: 1, SearchTerm: args[0], }) if err != nil { fmt.Println(errorStyle.Render(fmt.Errorf("error: %v", err).Error())) os.Exit(1) } items := convLPR2Items(packages) m := InitSearch(items) if _, err := tea.NewProgram(m, tea.WithAltScreen()).Run(); err != nil { fmt.Println(errorStyle.Render(fmt.Errorf("error: %v", err).Error())) os.Exit(1) } }, }
SearchCmd represents the init command
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.