Skip to content

Commit

Permalink
Extract files selector
Browse files Browse the repository at this point in the history
  • Loading branch information
mtojek committed Jan 11, 2021
1 parent 7965a61 commit a5d56a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion internal/download/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"google.golang.org/api/drive/v3"

"github.com/mtojek/gdriver/internal/driveext"
"github.com/mtojek/gdriver/internal/selector"
)

type FilesOptions struct {
Expand Down Expand Up @@ -41,7 +42,7 @@ func Files(driveService *drive.Service, options FilesOptions) error {

if options.SelectionMode {
fmt.Println("Select files to download")
files, err = selectFilesToDownload(files)
files, err = selector.SelectFiles(files, "download")
if err != nil {
return errors.Wrap(err, "can't select files to download")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package download
package selector

import (
"fmt"
"github.com/AlecAivazis/survey/v2"
"github.com/pkg/errors"

"github.com/mtojek/gdriver/internal/driveext"
)

func selectFilesToDownload(files driveext.DriveFiles) (driveext.DriveFiles, error) {
func SelectFiles(files driveext.DriveFiles, action string) (driveext.DriveFiles, error) {
fileSelectPrompt := &survey.MultiSelect{
Message: "Which files would you like to download?",
Message: fmt.Sprintf("Which files would you like to %s?", action),
Options: files.String(),
PageSize: 20,
}
Expand Down

0 comments on commit a5d56a5

Please # to comment.