*.go: fetching the books with progress bar

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2021-05-17 14:39:23 -05:00
parent cbb7bf1d6c
commit ebfd8ac60d
No known key found for this signature in database
GPG key ID: 524F155275DF0C3E
2 changed files with 66 additions and 9 deletions

View file

@ -47,13 +47,16 @@ to quickly create a Cobra application.`,
// Uncomment the following line if your bare application
// has an action associated with it:
Run: func(cmd *cobra.Command, args []string) {
b, err := goldenaudiobooks.BookScrape("https://goldenaudiobooks.com/the-water-dancer-oprahs-book-club-audiobook/")
if err != nil {
log.Fatal(err)
}
log.Debug(b)
if err = goldenaudiobooks.BookFetccher(b, ".", true); err != nil {
log.Fatal(err)
for _, arg := range args {
// "https://goldenaudiobooks.com/the-water-dancer-oprahs-book-club-audiobook/"
b, err := goldenaudiobooks.BookScrape(arg)
if err != nil {
log.Fatal(err)
}
log.Debug(b)
if err = goldenaudiobooks.BookFetcher(b, ".", viper.GetBool("create-local")); err != nil {
log.Fatal(err)
}
}
},
}
@ -79,6 +82,8 @@ func init() {
// Cobra also supports local flags, which will only run
// when this action is called directly.
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
rootCmd.Flags().StringP("dest", "d", ".", "destination base for fetched books")
rootCmd.Flags().BoolP("create-local", "C", false, "create files in local directory")
}
// initConfig reads in config file and ENV variables if set.