Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "gopixabay /path/to/output", Short: "gopixabay image downloader", Long: `gopixabay is an image downloader using the pixabay API`, Run: func(cmd *cobra.Command, args []string) { if len(args) != 1 { cmd.Help() return } validateSizeArgument() var result interface{} var err error switch arguments.request.ResponseGroup { case pbapi.ResponseGroupHighResolution: result, err = pbapi.QueryHighResolution(arguments.request) case pbapi.ResponseGroupImageDetails: result, err = pbapi.QueryImageDetails(arguments.request) default: log.Fatalf("Unknown response group: %s", arguments.request.ResponseGroup) } if err != nil { log.Fatal(err) } uiprogress.Start() wg := &sync.WaitGroup{} downloadChan := make(chan string) defer close(downloadChan) initWorkerThreads(args[0], wg, downloadChan) switch realResult := result.(type) { case *pbapi.HighResolutionResponse: for _, hit := range realResult.Hits { switch arguments.size { case og: downloadChan <- hit.ImageURL case lg: downloadChan <- hit.FullHDURL case md: downloadChan <- hit.LargeImageURL } } case *pbapi.ImageDetailsResponse: for _, hit := range realResult.Hits { switch arguments.size { case sm: downloadChan <- hit.WebFormatURL case xs: downloadChan <- hit.PreviewURL } } } wg.Wait() uiprogress.Stop() time.Sleep(time.Second) }, }
This represents the base command when called without any subcommands
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.