-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.go
48 lines (44 loc) · 1.27 KB
/
main.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
package main
import (
"fmt"
"github.com/bharatkalluri/moviescore/internal/getratings"
"github.com/ttacon/chalk"
"github.com/urfave/cli"
"os"
)
func main() {
app := cli.NewApp()
app.Name = "moviescore"
app.Usage = "A cli utility for showing Movie Ratings!"
app.UsageText = "MovieScore <Movie name here> (Please have quotes on either side if the movie name has spaces)"
app.Version = "0.1"
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "parentalguide, pg",
Usage: "Parental Guide from IMDB, Does not need the year argument.",
},
cli.BoolFlag{
Name: "reviews, r",
Usage: "Reviews, will be pulled from Rotten Tomatoes",
},
cli.StringFlag{
Name: "year, y",
Usage: "year of release, useful for rt ratings",
},
}
app.Action = func(c *cli.Context) error {
getratings.ASCIIPoster()
if c.Bool("parentalguide") == true && c.Bool("reviews") == true {
fmt.Println(chalk.Red, "One option at a time, cant have -pg and -r flags at the same time!")
}
if c.Bool("parentalguide") == true {
getratings.GetImdbParentsGuide(c.Args().Get(0))
} else if c.Bool("reviews") == true {
getratings.RtReviewScraper(c.Args().Get(0), c.String("year"))
} else {
getratings.PrettyPrinter(c.Args().Get(0), c.String("year"))
}
return nil
}
app.Run(os.Args)
}