Skip to content

Commit

Permalink
Get password interactively if not provided.
Browse files Browse the repository at this point in the history
  • Loading branch information
shahinam committed Jul 30, 2017
1 parent fc7c621 commit cd99536
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
14 changes: 13 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (c *Client) DownloadCourse(co *Course) {
filePath := filepath.Join(co.SaveDir, coursePath, fileName)
i++

fmt.Printf("Downloading: %s", link.Title)
fmt.Printf("Downloading Video: %s", link.Title)
videoURL, err := c.GetVideoUrl(link.URL, co)
if err != nil {
fmt.Printf(" ERROR: Unable to grab video file\n")
Expand Down
12 changes: 11 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import (
"flag"
"fmt"
"os"
"syscall"

"github.com/shahinam/cloudac-dl/client"

"golang.org/x/crypto/ssh/terminal"
)

var version = "1.1.0"
Expand Down Expand Up @@ -74,11 +77,18 @@ func parseCommandLineArgs() *CommandLineOptions {

flag.Parse()

if flag.NArg() == 0 || args.userName == "" || args.passWord == "" {
if flag.NArg() == 0 || args.userName == "" {
flag.Usage()
os.Exit(1)
}

// If password is not provided - get it interactively.
if args.passWord == "" {
fmt.Print("Please enter password: ")
password, _ := terminal.ReadPassword(int(syscall.Stdin))
args.passWord = string(password)
}

args.courseURL = flag.Arg(0)

return args
Expand Down

0 comments on commit cd99536

Please sign in to comment.