forked from pnicto/impartus-video-downloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.go
52 lines (40 loc) · 1.19 KB
/
ui.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"fmt"
"log"
)
func ChooseCourse(courses Courses) int {
log.Println("User entered choose course")
var choice int
fmt.Println("Choose a course to download from")
fmt.Println()
for i, course := range courses {
fmt.Printf("%3d %s\n", i+1, course.SubjectName)
}
fmt.Println()
fmt.Println("Enter a number")
// TODO: Check input is within range and a number
fmt.Scanf("%d", &choice)
log.Printf("User chose %d\n", choice)
log.Printf("Index is %d\n", choice-1)
CreateDirInsideDownloads(courses[choice-1].SubjectName)
return choice - 1
}
func ChooseLectures(lectures Lectures) (int, int) {
log.Println("User entered choose lecture")
var startIndex int
var endIndex int
fmt.Println("Choose a course to download from")
fmt.Println()
for i, lecture := range lectures {
fmt.Printf("%3d LEC %d %s\n", i+1, lecture.SeqNo, lecture.Topic)
}
fmt.Println()
// TODO: Add better range examples here
fmt.Println("Enter a range")
// TODO: Check input is within range and a number
fmt.Scanf("%d %d", &startIndex, &endIndex)
log.Printf("User chose %d %d\n", startIndex, endIndex)
log.Printf("Indices are %d %d\n", startIndex-1, endIndex-1)
return startIndex - 1, endIndex - 1
}