// Where all the work happens. func performCommand(cmd *cobra.Command, args []string) error { if displayVersion { fmt.Printf("%s %s\n", appName, version) return nil } if listProviders { fmt.Printf(providers.DisplayProviders()) return nil } query := strings.Join(args, " ") if query != "" { err := providers.Search(binary, provider, query, verbose) if err != nil { return err } } else { // Don't return an error, help screen is more appropriate. cmd.Help() } return nil }
// Where all the work happens. func performCommand(cmd *cobra.Command, args []string) error { if config.DisplayVersion { fmt.Printf("%s %s\n", appName, version) return nil } providers.SetBlacklist(config.Blacklist) providers.SetWhitelist(config.Whitelist) if config.ListProviders { fmt.Printf(providers.DisplayProviders()) return nil } if config.ServerMode { err := server.Run(config.Port, config.Cert, config.Key, config.Provider) if err != nil { return err } return nil } query := strings.Join(args, " ") st, err := os.Stdin.Stat() if err != nil { // os.Stdin.Stat() can be unavailable on Windows. if runtime.GOOS != "windows" { return fmt.Errorf("Failed to stat Stdin: %s", err) } } else { if st.Mode()&os.ModeNamedPipe != 0 { bytes, err := ioutil.ReadAll(os.Stdin) if err != nil { return fmt.Errorf("Failed to read from Stdin: %s", err) } query = strings.TrimSpace(fmt.Sprintf("%s %s", query, bytes)) } } if query != "" { err := providers.Search(config.Binary, config.Provider, query, config.Verbose) if err != nil { return err } } else { // Don't return an error, help screen is more appropriate. cmd.Help() } return nil }
// Where all the work happens. func performCommand(args []string) error { if displayVersion { fmt.Printf("%s %s\n", appName, version) return nil } if listProviders { fmt.Printf(providers.DisplayProviders()) return nil } query := strings.Join(args, " ") if query != "" { providers.Search(provider, query, verbose) return nil } else { // We don't display this, as the help screen is more useful. return fmt.Errorf("[Error] query is required.") } }
// Where all the work happens. func performCommand(cmd *cobra.Command, args []string) error { if displayVersion { fmt.Printf("%s %s\n", appName, version) return nil } if listProviders { fmt.Printf(providers.DisplayProviders()) return nil } query := strings.Join(args, " ") st, err := os.Stdin.Stat() if err != nil { return fmt.Errorf("Failed to stat Stdin: %s", err) } if st.Mode()&os.ModeNamedPipe != 0 { bytes, err := ioutil.ReadAll(os.Stdin) if err != nil { return fmt.Errorf("Failed to read from Stdin: %s", err) } query = strings.TrimSpace(fmt.Sprintf("%s %s", query, bytes)) } if query != "" { err := providers.Search(binary, provider, query, verbose) if err != nil { return err } } else { // Don't return an error, help screen is more appropriate. cmd.Help() } return nil }